Accessing a MySQL database in java

zdunham6287's Avatar, Join Date: Feb 2007
Go4Expert Member
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
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
You'll find a lot of help here http://www.caliberdt.com/tips/Feb2004.htm
0
zdunham6287's Avatar, Join Date: Feb 2007
Go4Expert Member
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.