求教:关于JDK1.6+TOMCAT5.5+SQL SERVER系统配置的问题
上一个相同的问题我已经将情况说明了,这里字数不够,就直接将DBO.java文件的代码放出来了,应该是第50行有问题,麻烦帮我看下,这个东西真是头疼。packagecom....
上一个相同的问题我已经将情况说明了,这里字数不够,就直接将DBO.java文件的代码放出来了,应该是第50行有问题,麻烦帮我看下,这个东西真是头疼。
package com.util;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.activation.DataSource;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
public class DBO {
private Connection conn;
private Statement stmt;
private DataSource ds;
public DBO()
{
}
/**
打开数据库
*/
public void open()
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databasename=cpyd","sa","123");
stmt=conn.createStatement();
System.out.println("打开数据库连接");
}
catch (Exception ex)
{
System.err.println("打开数据库时出错: " + ex.getMessage());
}
}
/**
关闭数据库,将连接返还给连接池
*/
public void close()
{
try
{
// connMgr.freeConnection("java", conn);
conn.close();
System.out.println ("释放连接");
}
catch (SQLException ex)
{
System.err.println("返还连接池出错: " + ex.getMessage());
}
}
/**
执行查询
*/
public ResultSet executeQuery(String sql) throws SQLException
{
ResultSet rs = null;
rs = stmt.executeQuery(sql);
System.out.println ("执行查询");
return rs;
}
/**
执行增删改
*/
public int executeUpdate(String sql) throws SQLException
{
int ret = 0;
ret = stmt.executeUpdate(sql);
System.out.println ("执行增删改");
return ret;
}
/**
将SQL语句加入到批处理
*/
public void addBatch(String sql) throws SQLException
{
stmt.addBatch(sql);
}
/**
执行批处理
*/
public int [] executeBatch() throws SQLException
{
boolean isAuto=conn.getAutoCommit();
conn.setAutoCommit(false);
int [] updateCounts = stmt.executeBatch();
// conn.commit();
// conn.setAutoCommit(isAuto);
//conn.setAutoCommit(true);
return updateCounts;
}
public boolean getAutoCommit() throws SQLException
{
return conn.getAutoCommit();
}
public void setAutoCommit(boolean auto) throws SQLException
{
conn.setAutoCommit(auto);
}
public void commit() throws SQLException
{
conn.commit();
// this.close();
}
public void rollBack() throws SQLException
{
conn.rollback();
// this.close();
}
}
这个是出问题的提示:
root cause
java.lang.NullPointerException
com.util.DBO.close(DBO.java:55)
com.bean.SystemBean.getSiteInfo(SystemBean.java:91)
org.apache.jsp.index_jsp._jspService(index_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs. 展开
package com.util;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.activation.DataSource;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
public class DBO {
private Connection conn;
private Statement stmt;
private DataSource ds;
public DBO()
{
}
/**
打开数据库
*/
public void open()
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databasename=cpyd","sa","123");
stmt=conn.createStatement();
System.out.println("打开数据库连接");
}
catch (Exception ex)
{
System.err.println("打开数据库时出错: " + ex.getMessage());
}
}
/**
关闭数据库,将连接返还给连接池
*/
public void close()
{
try
{
// connMgr.freeConnection("java", conn);
conn.close();
System.out.println ("释放连接");
}
catch (SQLException ex)
{
System.err.println("返还连接池出错: " + ex.getMessage());
}
}
/**
执行查询
*/
public ResultSet executeQuery(String sql) throws SQLException
{
ResultSet rs = null;
rs = stmt.executeQuery(sql);
System.out.println ("执行查询");
return rs;
}
/**
执行增删改
*/
public int executeUpdate(String sql) throws SQLException
{
int ret = 0;
ret = stmt.executeUpdate(sql);
System.out.println ("执行增删改");
return ret;
}
/**
将SQL语句加入到批处理
*/
public void addBatch(String sql) throws SQLException
{
stmt.addBatch(sql);
}
/**
执行批处理
*/
public int [] executeBatch() throws SQLException
{
boolean isAuto=conn.getAutoCommit();
conn.setAutoCommit(false);
int [] updateCounts = stmt.executeBatch();
// conn.commit();
// conn.setAutoCommit(isAuto);
//conn.setAutoCommit(true);
return updateCounts;
}
public boolean getAutoCommit() throws SQLException
{
return conn.getAutoCommit();
}
public void setAutoCommit(boolean auto) throws SQLException
{
conn.setAutoCommit(auto);
}
public void commit() throws SQLException
{
conn.commit();
// this.close();
}
public void rollBack() throws SQLException
{
conn.rollback();
// this.close();
}
}
这个是出问题的提示:
root cause
java.lang.NullPointerException
com.util.DBO.close(DBO.java:55)
com.bean.SystemBean.getSiteInfo(SystemBean.java:91)
org.apache.jsp.index_jsp._jspService(index_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs. 展开
3个回答
仁科信息
2024-07-24 广告
2024-07-24 广告
Oracle EBS运维是确保企业资源规划系统稳定、高效运行的关键环节。它涵盖了系统监控、性能优化、故障排查与恢复等多方面内容。通过持续的监控和数据分析,运维团队能够及时发现并解决潜在问题,保障系统的稳定性和安全性。同时,他们还需要与业务部...
点击进入详情页
本回答由仁科信息提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询