• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

websphere studio and mysql

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
}
}
}
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic