• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MySQL

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy,

I'm writing a bare-bones java-struts app in WebSphere using MySQL just to prove to myself that I can do it. For the sake of complexity, I created an enterprise app with a web-app in it (which is where I'm attempting to connect to the db).

Without going into painful detail, what I have so far worked fine until I added the database connection code that follows:
==========================================================
String database = config.getProperty("database");
String user = config.getProperty("user");
String password = config.getProperty("password");
String strConn = "jdbc:mysql://localhost/"+database+"?"+"user="+user+"&password="+password;

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException e) {
System.out.println("InstantiationException = "+e.toString());
} catch (IllegalAccessException e) {
System.out.println("IllegalAccessException = "+e.toString());
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundExcetpion = "+e.toString());
}

try {
conn =
(Connection) DriverManager.getConnection(strConn);
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}

return conn;
} // method
==========================================================
The problem I'm experiencing is that when I step over the DriverManager.getConnection() call, the app just hangs and doesn't come back. Hulk not know where it go.

Note that the jar file with the driver (mysql-connector-java-3.1.7-bin.jar) is in the web project's lib directory and the web project's java build path is correctly pointing to it. The current value of strConn (the connection string) is
"jdbc:mysql://localhost/struts_mysql?user=root&password="
I do indeed have a database called struts_mysql (in case you were curious).
I'm without a clue as to what is happening and where the code is going. I'm open to all suggestions (I've tried the 'more beer' option but while relaxing, it isn't helping).

Regards,

- DM_Tim
[ February 28, 2005: Message edited by: Tim Manchester ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a search for the "SquirrelSQL" database client. It's my first point of call for database connection problems since it allows you to test the driver, jdbc url and connection outside your application. Then apply more beer.
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic