Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3662804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:27:30+00:00 2026-05-19T01:27:30+00:00

So I have a MySQL database set up on a Debian server and it

  • 0

So I have a MySQL database set up on a Debian server and it works fine from a phpMyAdmin client. I’m currently working on a project to write a Java server that would be able to use the MySQL database that is already on this server through a JDBC connection. I’ve looked at many tutorials and documentations but all of them seem to just explain how to do client-side code, but I have yet to figure out how to even successfully open a JDBC connection to the server. As far as I am concerned, I believe that program has the drivers properly set up because it’s not crashing anymore (I simply direct the Java Build Path of my program to the Connector/J provided by MySQL). As far as my program goes, this is what it looks like…

import java.sql.*;

public class JDBCTest {
    public static void main(String[] args) {
        System.out.println("Started!");
        try {
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            System.out.println("Driver registered. Connecting...");
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/", "root", "password");
            System.out.println("Connected!");
            conn.close();
        } catch (SQLException e) {
            System.out.println("Error!");
            e.printStackTrace();
        }
    }
}

This is what’s printed…

Started!
Driver registered. Connecting...

It’s as if the DriverManager.getConnection(String) just freezes there. I’m sure this is a problem with the server because when I intentionally misspell localhost, or an IP address, the program crashes within 20 seconds. This just hangs there forever.

Sorry about this wall of text, but my final question is if anyone has any information what I should do or install on the server to get this to work? Thank you so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:27:31+00:00Added an answer on May 19, 2026 at 1:27 am

    Try following:

    public class MySqlDemo {
    
    public static void main(String [] args) {
    
            java.sql.Connection conn = null;
    
            System.out.println("SQL Test");
    
            try {
                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                    conn = java.sql.DriverManager.getConnection(
                            "jdbc:mysql://localhost:3306/test?user=root&password=");
    
            }
            catch (Exception e) {
                    System.out.println(e);
                    System.exit(0);
                    }
    
            System.out.println("Connection established");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a MySQL database set up with a Java client accessing and
I have a MySQL database set-up in a hierarchy style. There are 4 tables
I have a MySQL database where the table was set up to store the
Okay, so I have a MySQL database set up. Most of the tables are
I have a mysql database which have set of tables One table have a
I have a mysql database set as utf-8, and csv data set as utf-8,
I have a MySQL database from which a view is created. Is is possible
I have a MySQL database set up on 000webhost.com. I want to access the
Ok, so I've installed xampp 1.7.7 and have my mysql database set up and
I have a MySQL Database on my server. I need my android app to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.