private LoginActionForm getUserInfo(String userName,String userPassword,String sessionid)throws SQLException {
LoginActionForm myform=null;
Connection conn=null;
Statement stmt=null;
Statement stmt1=null;
ResultSet rs=null;
ResultSet rs1=null;
String sql="SELECT * FROM USERPURVIEW WHERE USERNAME='"+userName+"' and USERPASSWORD='"+userPassword+"'"; System.out.println(sql);
BaseDAO dao=new BaseDAO();
try{
dao.Open();
conn=dao.getConnection();
stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //运行到此步时程序自动跳到System.out.println("connection is error");行
if(rs!=null){
while(rs.next()){
。
。。内容省略
}catch(SQLException e){
System.out.println("connection is error");
throw new SQLException(e.getMessage());
}finally{
dao.CloseCon();
}
return myform;
}是哪里出错了?
LoginActionForm myform=null;
Connection conn=null;
Statement stmt=null;
Statement stmt1=null;
ResultSet rs=null;
ResultSet rs1=null;
String sql="SELECT * FROM USERPURVIEW WHERE USERNAME='"+userName+"' and USERPASSWORD='"+userPassword+"'"; System.out.println(sql);
BaseDAO dao=new BaseDAO();
try{
dao.Open();
conn=dao.getConnection();
stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //运行到此步时程序自动跳到System.out.println("connection is error");行
if(rs!=null){
while(rs.next()){
。
。。内容省略
}catch(SQLException e){
System.out.println("connection is error");
throw new SQLException(e.getMessage());
}finally{
dao.CloseCon();
}
return myform;
}是哪里出错了?
解决方案 »
- spring3.0整合hibernate3.3 save is not valid without active transacton
- 关于struts2和jsp的问题
- Linux tomcat 服务有很多8009,,到后来heap 内存不足
- ireport 第二问,如何控制分页??
- Xfire中,通过"Creat WebService from java bean" 生成的WebService有问题。
- 高薪诚聘java程序员
- 一个简单的struts题目,谁帮忙看下!
- linux 下 hibernate 缓存文件放置路径问题
- 我面临一个选择C#还是JAVA的问题,大家帮帮我1
- javamail接收邮件疑难问题(望java望高手给于解答,高分相送)
- 关于我的面试
- 难题: 如何实现类似QQ消息的收发方式?
System.out.println("connection is error");
e.printStackTrece() throw new SQLException(e.getMessage());
}finally{
dao.CloseCon();
}
public class SQLException extends java.lang.Exception {
public SQLException(String reason, String SQLState, int vendorCode) {
super(reason);
this.SQLState = SQLState;
this.vendorCode = vendorCode;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
DriverManager.println("SQLException: SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
printStackTrace(DriverManager.getLogWriter());
}
}
} public SQLException(String reason, String SQLState) {
super(reason);
this.SQLState = SQLState;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
DriverManager.println("SQLException: SQLState(" + SQLState + ")");
}
}
}
public SQLException(String reason) {
super(reason);
this.SQLState = null;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
public SQLException() {
super();
this.SQLState = null;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
public String getSQLState() {
return (SQLState);
}
public int getErrorCode() {
return (vendorCode);
}
public SQLException getNextException() {
return (next);
}
public synchronized void setNextException(SQLException ex) {
SQLException theEnd = this;
while (theEnd.next != null) {
theEnd = theEnd.next;
}
theEnd.next = ex;
}
private String SQLState;
private int vendorCode;
private SQLException next;
}
System.out.println(e.getMessage());
}这样输入你的异常看看。
System.out.println("connection is error");
e.printStackTrece()
}finally{
dao.CloseCon();
}
这样也行。。
conn=dao.getConnection();你确定这个能连接上?