救命啊!!为什么还是错
package myConnection;
import java.lang.*;
import java.sql.*;
public class connDB {
Connection conn;
ResultSet rs;
ResultSetMetaData rsmd;
Statement stmt;
//String driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver";
//String jdbcURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Test";
String driverName="sun.jdbc.odbc.JdbcOdbcDriver";
String jdbcURL="jdbc:odbc:Test";
String username="Alan";
String password="";
public connDB(){
conn=null;
rs=null;
rsmd=null;
stmt=null;
try{
Class.forName(driverName);
}
catch(ClassNotFoundException e){
}
}
public ResultSet execQuery(String sql){
if(sql==null){
System.out.println("查询语句不能为空。");
}
try{
conn=DriverManager.getConnection(jdbcURL,username,password);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException eq){
}
return rs;
}
public int execUpdate(String sql){
int result=0;
try{
stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException eu){
}
return result;
}
public void rsClose() throws Exception{
if(rs!=null){
rs.close();
rs=null;
}
}
public void stmtClose() throws Exception{
if(stmt!=null){
stmt.close();
stmt=null;
}
}
public void connClose() throws Exception{
if(conn!=null || !conn.isClosed()){
conn.close();
conn=null;
}
}
public void closeAll() throws Exception{
rsClose();
stmtClose();
connClose();
}
}
jsp也面:
<jsp:useBean id="connDB" class="myConnection.connDB" scope="page"/>
//String sql1="update userInfo set addr='hhh' where id=1";
String sql2="select * from userInfo";
ResultSet rs=connDB.execQuery(sql2);
这样写的没提示什么错误,但是加上rs.next();就出现错误。
极度郁闷~~
请各位大侠帮帮忙呀
错误信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NullPointerException
org.apache.jsp.testSql_jsp._jspService(testSql_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
import java.lang.*;
import java.sql.*;
public class connDB {
Connection conn;
ResultSet rs;
ResultSetMetaData rsmd;
Statement stmt;
//String driverName="com.microsoft.jdbc.sqlserver.SQLServerDriver";
//String jdbcURL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Test";
String driverName="sun.jdbc.odbc.JdbcOdbcDriver";
String jdbcURL="jdbc:odbc:Test";
String username="Alan";
String password="";
public connDB(){
conn=null;
rs=null;
rsmd=null;
stmt=null;
try{
Class.forName(driverName);
}
catch(ClassNotFoundException e){
}
}
public ResultSet execQuery(String sql){
if(sql==null){
System.out.println("查询语句不能为空。");
}
try{
conn=DriverManager.getConnection(jdbcURL,username,password);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException eq){
}
return rs;
}
public int execUpdate(String sql){
int result=0;
try{
stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException eu){
}
return result;
}
public void rsClose() throws Exception{
if(rs!=null){
rs.close();
rs=null;
}
}
public void stmtClose() throws Exception{
if(stmt!=null){
stmt.close();
stmt=null;
}
}
public void connClose() throws Exception{
if(conn!=null || !conn.isClosed()){
conn.close();
conn=null;
}
}
public void closeAll() throws Exception{
rsClose();
stmtClose();
connClose();
}
}
jsp也面:
<jsp:useBean id="connDB" class="myConnection.connDB" scope="page"/>
//String sql1="update userInfo set addr='hhh' where id=1";
String sql2="select * from userInfo";
ResultSet rs=connDB.execQuery(sql2);
这样写的没提示什么错误,但是加上rs.next();就出现错误。
极度郁闷~~
请各位大侠帮帮忙呀
错误信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NullPointerException
org.apache.jsp.testSql_jsp._jspService(testSql_jsp.java:77)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
...全文
相关推荐
js中!和!!的区别与用法
js中!的用法是比较灵活的,它除了做逻辑运算常常会用!做类型判断,可以用!与上对象来求得一个布尔值, 1、!可将变量转换成boolean类型,null、undefined和空字符串取反都为false,其余都为true。 !null=true !undefined=true !''=true !100=false !'abc'=false 2、!!常常用来做类型判断,在第一步!(变量)之后再做逻辑取反运算,在js中新手常常会写这样臃肿的代码: 判断变量a为非空,未定义或者非空串才能执行方法体的内容 var a; if(a!=null&&typeof(a)!=undefined&&a!='')
《救命骨髓》01.ppt
《救命骨髓》01.ppt
MATLAB图像错切_matlab_图像处理_水平错切_图像错切_
读入一幅图像,对其进行水平错切、垂直错切
救命啊,两宿舍美女都在追我
救命啊,两宿舍美女都在追我
白蛇救命_csdn
白蛇救命


Web 开发
