Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Accessing a MySQL database in java (http://www.go4expert.com/forums/accessing-mysql-database-java-t3446/)

zdunham6287 17Mar2007 05:45

Accessing a MySQL database in java
 
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?

pradeep 17Mar2007 11:18

Re: Accessing a MySQL database in java
 
You'll find a lot of help here http://www.caliberdt.com/tips/Feb2004.htm

zdunham6287 18Mar2007 02:51

Re: Accessing a MySQL database in java
 
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.


All times are GMT +5.5. The time now is 17:11.