Computing.Net > Forums > Programming > Hello unable to connect to database

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Hello unable to connect to database

Reply to Message Icon

Name: kris2976
Date: July 8, 2009 at 00:14:54 Pacific
OS: Windows XP professional
Subcategory: Java
Comment:

Hi
public static Connection connectToDB() {

Connection conn = null;
try {
System.err.println("Tring to find driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
// Class.forName("org.gjt.mm.mysql.Driver").newInstance();

// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


System.err.println("driver found");
} catch (Exception e) {
System.err.println("Unable to find and load driver");
}





try {

System.err.println("Tring to Connect To Database");

// conn = DriverManager.getConnection("jdbc:mysql://localhost/trace?user=root&password=");

conn = DriverManager.getConnection("jdbc:mysql://10.239.126.12/trace?user=root&password=");

System.err.println("Connected To Database");

} catch (SQLException ex) {

ex.printStackTrace();
// System.out.println("SQLException: " + ex.getMessage());
// System.out.println("SQLState: " + ex.getSQLState());
// System.out.println("VendorError: " + ex.getErrorCode());
// System.err.println("Cant connected to Database.");
// displaySQLErrors(ex);
}

catch (Exception e) {

e.printStackTrace();
}



return conn;
}



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Hello unable to connect to database

Connecting to database using .UDL f www.computing.net/answers/programming/connecting-to-database-using-udl-f/5278.html

establish a connection to database www.computing.net/answers/programming/establish-a-connection-to-database/18670.html

Database connection in VB.NET www.computing.net/answers/programming/database-connection-in-vbnet/11398.html