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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error due to accessing database connection using jsp

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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>
<hr>
<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: 8 in the jsp file: /database.jsp

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


An error occurred at line: 8 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)
^


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

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

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:552)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)

Anybody help me?
Thanx in advance
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Plase do not post the same question more than once.
 
Water! People swim in water! Even tiny ads swim in water:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic