Accessing a MySQL database in java

Discussion in 'Java' started by zdunham6287, Mar 17, 2007.

  1. zdunham6287

    zdunham6287 New Member

    Joined:
    Feb 7, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania, USA
    Home Page:
    http://www.tombradyfansite.com
    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 a moderator: Mar 17, 2007
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
  3. zdunham6287

    zdunham6287 New Member

    Joined:
    Feb 7, 2007
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Pennsylvania, USA
    Home Page:
    http://www.tombradyfansite.com
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice