package org.wdj;
import java.sql.*;
public class Success {
/**
* @param args
*/
private Connection con=null;
private final String DRIVER= "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
private final String URL= "jdbc:microsoft:sqlserver://127.0.0.1:1433;database=test ";
private final String name= "sa ";
private final String pass= "sa ";
private PreparedStatement pstm=null;
private ResultSet rs=null;
private String sql= "select * from biao ";
public Success(){
try{
Class.forName(DRIVER);
con=DriverManager.getConnection(URL,name,pass);
}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO 自动生成方法存根
Success s=new Success();
s.disp();
}
public void disp(){
try{
rs=con.prepareStatement(sql).executeQuery();
while(rs.next()){
System.out.print(rs.getString(1));
}
pstm.close();
rs.close();
con.close();
}
catch(Exception e){
e.printStackTrace();
}
finally{
try {
con.close();
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
}
------解决方案--------------------
biao
你数据库中有这个表吗
------解决方案--------------------
select * from biao
将这句Sql放到查询分析器里面看看有问题吗?
------解决方案--------------------
test下面建叫 'biao '的表没?