Unsubscribe from Question

How to create MySql connection using jsp through Tomcat ver 5.5?

My codding is:

<%@ page import = "java.sql.*"%>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:odbc:MyProject1");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from employee");
while(rs.next()){
out.println("MFR: "+rs.getString(2));
out.println("Total Weight: "+rs.getString(3));
}
}
catch(ClassNotFoundException e){
out.println("Class not found");
e.printStackTrace();
}
catch(SQLException e){
out.println("sql");
e.printStackTrace();
}
%>

But it is not displaying the records instead sql exception is coming. Please help me with this the problem.

Regards
Salim


Nov 30, 2007 - Salim Akhtar

Answers

Could you please post the entire error message. I guess It's a problem with the mysql driver. Don't forget that the jar file corresponding to the driver must be in the classpath.

Bye.

Dec 08, 2007 -
julio.delgadomangas
Have you created the DSN MyProject1? How many columns your Table has? Give me the full stack trace for the SQL exception...

Dec 10, 2007 -
steve12367




<%@ page language="java" import="java.sql.*" %>
<%
int count=0 ;
Connection con=null;
ResultSet rst=null;
Statement stmt=null;

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:urDSN");



stmt=con.createStatement();

rst=stmt.executeQuery("select * from books_details " );

while(rst.next())
{
count++;
%>






<% }
}
catch(Exception e){
out.println(e.getMessage());
}

%>



Apr 30, 2008 - sucess233
S NoBook_nameAuthor
<%= count %> <%= rst.getString(1) %> <%= rst.getString(2) %>
1 - 3 of 3 First | Previous | Next | Last  
Newsletter
Copyright © 2013 VisualBuilder. All rights reserved

Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0