import java.net.URL;
import java.sql.*;
class Chaxun
{
public static void main(String args[])
{
String l="jdbc:odbc:PUB";
try
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNOtFoundException:");
System.err.println(e.getMessage());
}
Connection con=DriverManager.getConnection(l,"sa","kelly");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(" select * from titles where pub_id='1389' ");
System.out.println("This is content"+rs.getString("title_id"));
con.close();
}
catch(SQLException ex)
{
while(ex!=null)
{
System.out.println("数据库异常被捕获了");
System.out.println(ex.getSQLState());
System.out.println(ex.getMessage());
System.out.println(ex.getErrorCode());
ex=ex.getNextException();
}
}
}
}
我运行这个程序的时候
总是说无效的游标状态
但是表中的确有这个纪录的
关于这句where pub_id='1389'我用=和like都不行
还想问问,如果一个字符串只知道前3位
想查找它该如何书写呢
谢谢