Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

websphere studio and mysql

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have websphere studio 5.0. I have downloaded the mysql jar file(mysql-connector-java-3.0.11-stable-bin.jar). I placed it in
"C:\Program Files\IBM\SQLLIB\java" . I wrote a simple dbase program trying to access database. Everytime I run the code it says "driver problem".
I am able to get connected thru data perspective in websphere studio. I have no clue why I get this when I connect thru my code?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class dbservlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String mydatabase = "test";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "root";
String password = "root";
connection = DriverManager.getConnection(url, username, password);
out.println("connected");
} catch (ClassNotFoundException e) {
out.println("driver problem");
} catch (SQLException e) {
out.println("not connected");
}
}
}
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic