我写了用JAVA读取DBF的例子,一般的文件可以正确读写,可是有一个不行报下面的错,
请问一下,这可能是啥原因引起的?Exception java.sql.SQLException: [Microsoft][ODBC dBase Driver] 所有记录中均未找到搜索关键字。附:源代码如下,请指路 public void readdbFile(){
Connection con = null;
long begin = System.currentTimeMillis();
//数据库连接
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=D:\\hangqing2;","","");
System.out.println("连接成功!");
}catch(Exception e){
System.out.println("数据库连接"+e);
}
boolean logic = true;
ArrayList list = new ArrayList();
while(logic){
try{
Statement stmt = con.createStatement();
String sql = "select * from SHOW20031";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String stockno = rs.getString(1);
System.out.println("stockno = "+stockno);
;
if(!list.contains(stockno.substring(0,3))){
list.add(stockno.substring(0,3));
}
}
rs.close();
stmt.close();
}catch(Exception e){
System.out.println("Exception "+e);
}
logic = false;
}
System.out.println("**********************************");
int size = list.size();
for(int i = 0; i < size; i++){
System.out.println(i+":"+list.get(i));
}
}我的主页:http://free2.e-168.cn/lovelyhome/index.jsp
请问一下,这可能是啥原因引起的?Exception java.sql.SQLException: [Microsoft][ODBC dBase Driver] 所有记录中均未找到搜索关键字。附:源代码如下,请指路 public void readdbFile(){
Connection con = null;
long begin = System.currentTimeMillis();
//数据库连接
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=D:\\hangqing2;","","");
System.out.println("连接成功!");
}catch(Exception e){
System.out.println("数据库连接"+e);
}
boolean logic = true;
ArrayList list = new ArrayList();
while(logic){
try{
Statement stmt = con.createStatement();
String sql = "select * from SHOW20031";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
String stockno = rs.getString(1);
System.out.println("stockno = "+stockno);
;
if(!list.contains(stockno.substring(0,3))){
list.add(stockno.substring(0,3));
}
}
rs.close();
stmt.close();
}catch(Exception e){
System.out.println("Exception "+e);
}
logic = false;
}
System.out.println("**********************************");
int size = list.size();
for(int i = 0; i < size; i++){
System.out.println(i+":"+list.get(i));
}
}我的主页:http://free2.e-168.cn/lovelyhome/index.jsp
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货