Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 8th, 2006, 06:54 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default error accessing database connection using jsp

Hi,

I have an error, during accessing a datbase using jsp:useBean from jsp.Urgent i need this one
my source code is



DbBean.java

package SQLBean;
import java.sql.*;
import java.io.*;

public class DbBean implements java.io.Serializable{

private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;

public DbBean(){
super();
}

public boolean connect() throws ClassNotFoundException,SQLException{
Class.forName(dbDriver);
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
}



public void close() throws SQLException{
dbCon.close();
}

public ResultSet execSQL(String sql) throws SQLException{

Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}

}


database.jsp
<HTML>
<HEAD><TITLE>DataBase Search</TITLE></HEAD>
<BODY>

<%@ page language="Java" import="java.sql.*" %>

<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />

<jsp:setProperty name="db" property="*" />

<center>
<h2> Results from </h2>

<br><br>
<table>

<%
db.connect();


ResultSet rs = db.execSQL("select * from employ");
int i = db.updateSQL("UPDATE employ set fname = 'hello world' where empno='000010'");
out.println(i);



%>

<%
while(rs.next()) {
%>
<%= rs.getString("empno") %>
<BR>
<%
}
%>
<BR>
<%

db.close();

%>

Done

</table>

</body>

</HTML>


The error like this

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
error: Invalid class file format in C:\Program Files\Apache Tomcat 4.0\webapps\muthu\WEB-INF\classes\SQLBean\DbBean.class. The major.minor version '49.0' is too recent for this tool to understand.


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:65: Class SQLBean.DbBean not found.
SQLBean.DbBean db = null;
^


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:68: Class SQLBean.DbBean not found.
db= (SQLBean.DbBean)
^


An error occurred at line: 7 in the jsp file: /database.jsp

Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\localhost\muthu\database$jsp.java:73: Class SQLBean.DbBean not found.
db = (SQLBean.DbBean) java.beans.Beans.instantiate(this.getClass().getCl assLoader(), "SQLBean.DbBean");
^
4 errors, 1 warning

Anybody help me?
Thanx in advance

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Database connection error lappling General .NET 0 April 20th, 2006 08:48 AM
Database connection error help me hasham Pro JSP 1 March 21st, 2006 08:38 AM
Database Connection Error werD420 Classic ASP Databases 12 January 20th, 2005 01:52 PM
about jsp database connection qiezi Java Databases 4 December 20th, 2004 08:26 AM



All times are GMT -4. The time now is 12:19 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.