使用jdbc-odbc连接mysql.出现java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY!

chinaITman 2002-11-28 05:43:58
附原程序!多谢!
import java.awt.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
/**
* This class can take a variable number of parameters on the command
* line. Program execution begins with the main() method. The class
* constructor is not invoked unless an object of type 'Class1'
* created in the main() method.
*/
public class Class1
{
/**
* The main entry point for the application.
*
* @param args Array of parameters passed to the application
* via the command line.
*/
public static void main (String[] args)
{
Connection connection=null;
Statement statement=null;
ResultSet result1=null;
String tempstr=null;
int tempnum;
System.out.println("database connect;");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{System.out.println("class error!");
System.out.println(e.getMessage());
}

try{
connection=DriverManager.getConnection("jdbc:odbc:onlinegame");
}
catch(Exception e)
{System.out.println("connect error!");}

try{
statement=connection.createStatement();
}
catch(Exception e)
{System.out.println("connect error!");}

String sql="select * from wuzhi";
try{
result1=statement.executeQuery("select * from wuzhi where username='aaasss'");
result1.beforeFirst();
// tempnum=result1.getInt("num");
System.out.println("username:"+result1.getInt("num"));
}
catch(Exception e)
{System.out.println(e);
}
System.out.println(tempstr);
// TODO: Add initialization code here
}

public Class1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
}
}
...全文
26 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fastmask 2002-11-29
  • 打赏
  • 举报
回复
实在没有办法,你就避免滚动了,就next一直用就行了。要放开思路吗。
alphazhao 2002-11-29
  • 打赏
  • 举报
回复
干吗用jdbc-odbc桥连接数据库??
这样生成的结果集是不支持滚动光标的说
hotenM 2002-11-29
  • 打赏
  • 举报
回复
没事情滚rs干什么?
用next足够了
dulcetYang 2002-11-29
  • 打赏
  • 举报
回复
期待。
mysql自己的驱动是一样的。目前好像不支持SCROLLABLE类型的数据集。期待你的答案
dulcetYang@sohu.com
xue_sharp 2002-11-28
  • 打赏
  • 举报
回复
改用mysql自己的jdbc驱动

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧