Results 1 to 9 of 9
- 03-29-2009, 07:20 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
[SOLVED] mysql problem using eclipse
hello everybody,
i'm having trouble geeting results back from mysql server through eclipse. i know it works and code is fine however i cant get the results to show in eclipse.
Servlet code:
and the error message is:Java Code:package staffPackage; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import java.sql.*; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class DisplayEmployees */ public class DisplayEmployees extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public DisplayEmployees() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub //super.doGet(request, response); Connection conn =null; // Create connection object String database = "NotForYourEyes"; // Name of database String user = "NotForYourEyes"; // String password = "NotForYourEyes"; String url = "NotForYourEyes" + database; String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "+ "Transitional//EN\"\n" + "\">"; response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(docType); try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch(Exception e) { System.err.println(e); } // connecting to database try { conn = DriverManager.getConnection(url, user, password); //String selectSQL = "select * from students,degrees WHERE students.degreecode = degrees.degreecode"; String selectSQL = "select * from Staff"; System.err.println("DEBUG: Query: " + selectSQL); Statement stmt = conn.createStatement(); ResultSet rs1 = stmt.executeQuery(selectSQL); out.println("<Center><H1>List of Staff Members</Center>"); // print out table header out.println("<table border=\"1\" cellspacing=\"5\" cellpadding=\"5\">" + "<tr><th>Staff ID</th><th>Surname</th><th>Forename</th><th>Current Work Status</th></tr>" ); while(rs1.next()){ out.print("<tr>"); out.print("<td>" + rs1.getString("StaffID") + "</td>"); out.print("<td>" + rs1.getString("surname") + "</td>"); out.print("<td>" + rs1.getString("forename") + "</td>"); out.print("<td>" + rs1.getString("currentWorkStatus") + "</td>"); } } catch(SQLException e) { System.err.println(e); } //print out table rows one for each row returned in rs1 //Close table out.println("</table>"); //CLose HTML out.println("</body></head>"); } }
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver found for jdbc....(address)
i'm guessing a plugin is need or a path of somesort, any ideas?
- 04-02-2009, 09:37 PM #2
First of all open the mysql config file - my.cnf and delete the line:
Post here what libs of MySQL do you use to run the codeJava Code:skip-networking
- 04-13-2009, 12:37 AM #3
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
i'm using - mysql-connector-java-5.0.8 (not 100% its the right plugin?)and there is no file called my.cnf? i'm also using tomcat 6 withing eclipse in windows. im not really sure how to get a list of my plugins. also i managed to get the quantum db plugin working so it is possible to connect to the mysql db. when i try to connect i still get error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Error in java.sql.SQLException: No suitable driver found for jdbc:mysql://...address
- 04-13-2009, 12:56 AM #4
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
or if any body has a working sample that works through eclipse with plugins used would be helpfull. thanks
- 04-13-2009, 08:58 AM #5
my.cnf file is a MySQL configuration file in the path, where you installed MySQL
- 04-13-2009, 08:59 AM #6
Then put mysql-connector-java-5.0.8.jar into the tomcat libs folder
- 04-13-2009, 02:37 PM #7
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
i dont have anything for mysql installed that has my.cnf in it. i've moved th mysql-connector jar to tomcat and i dont get any error messages but nothing happens so i guess were oon the right track
- 04-13-2009, 07:51 PM #8
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
- 04-13-2009, 08:08 PM #9
Similar Threads
-
Connector J with Eclipse and MySQL 5.0.x
By int80 in forum EclipseReplies: 11Last Post: 05-31-2010, 09:32 AM -
How to access MySQL Database in Eclipse 3.2
By nijava in forum EclipseReplies: 2Last Post: 12-12-2008, 03:04 PM -
Eclipse / Mysql problem
By jdevm in forum EclipseReplies: 0Last Post: 10-09-2008, 01:16 AM -
mysql driver problem
By mokingsu in forum JDBCReplies: 4Last Post: 01-17-2008, 05:27 PM -
Mysql problem
By Nick15 in forum JDBCReplies: 2Last Post: 05-15-2007, 05:07 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks