Accessing a MySQL database in java

Go4Expert Member
17Mar2007,05:45   #1
zdunham6287's Avatar
I've written a java program to insert data into a MySQL database hosted on godaddy.com, I'm still having trouble connecting to the database though.

Code:
       Connection connection = null;   
        try 
        { // load the driver 
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch( Exception e ) 
        { // problem loading driver, class not exist?
            e.printStackTrace();
            return;
        }
        try 
        {
            connection = DriverManager.getConnection("jdbc:mysql://mysqladmin2.secureserver.net/277/","LyricsWhoreMain","imanidiot777");
I downloaded the necessary driver for a MySQL connection, I'm not totally sure about what to change the class path to, I figured out how to change it though, can anyone help me get a database connection working?

Last edited by shabbir; 17Mar2007 at 08:35.. Reason: Code formatting
Team Leader
17Mar2007,11:18   #2
pradeep's Avatar
You'll find a lot of help here http://www.caliberdt.com/tips/Feb2004.htm
Go4Expert Member
18Mar2007,02:51   #3
zdunham6287's Avatar
That helped me with the driver part thanks, now my other problem is that I get a connection timing out every time I try to connect. I have no idea how to fix that.