/*
* Created on 2006-1-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.yourcompany.struts.bean;import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;/**
* 创建者: oath
* 创建时间:2006-1-11
* 任务:TODO
*/
public class A { public static void main(String[] args) {
Connection con = DBConnection.getDBConnection(); String tableName = "admin";//数据库用户表信息表 ResultSet result = null;
Statement stmt = null;
boolean pass = false;
try {
stmt = con.createStatement();
System.out.println("aaaaaaaa ");
String isCorrect = "select * from book";
result = stmt.executeQuery(isCorrect);
if (!result.next())
{
} else {
pass = true;
} } catch (Exception e) {
System.out.println("error1 is " + e);
} finally {
try {
stmt.close();
con.close();
} catch (SQLException ex) {
System.out.println("error2 is " + ex);
}
}
}
}
***************************************************
控制台输出:aaaaaaaa
error1 is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'book' 无效。
sql2000打了sp3,应该已经建立了连接(因为输出了aaaaaaa)。book表是肯定在con连接的数据库里面的,换成其他表名还是提示无效,这是什么原因呢?
* Created on 2006-1-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.yourcompany.struts.bean;import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;/**
* 创建者: oath
* 创建时间:2006-1-11
* 任务:TODO
*/
public class A { public static void main(String[] args) {
Connection con = DBConnection.getDBConnection(); String tableName = "admin";//数据库用户表信息表 ResultSet result = null;
Statement stmt = null;
boolean pass = false;
try {
stmt = con.createStatement();
System.out.println("aaaaaaaa ");
String isCorrect = "select * from book";
result = stmt.executeQuery(isCorrect);
if (!result.next())
{
} else {
pass = true;
} } catch (Exception e) {
System.out.println("error1 is " + e);
} finally {
try {
stmt.close();
con.close();
} catch (SQLException ex) {
System.out.println("error2 is " + ex);
}
}
}
}
***************************************************
控制台输出:aaaaaaaa
error1 is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'book' 无效。
sql2000打了sp3,应该已经建立了连接(因为输出了aaaaaaa)。book表是肯定在con连接的数据库里面的,换成其他表名还是提示无效,这是什么原因呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货