当前位置: 技术问答>java相关
我到底是错在哪里?
来源: 互联网 发布时间:2015-05-07
本文导语: 大家好,请帮我看看下面的代码: import java.sql.*; class Database{ public static void main(String args[]) { String url = "jdbc:odbc:erp"; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection(url,"sa",""); ...
大家好,请帮我看看下面的代码:
import java.sql.*;
class Database{
public static void main(String args[])
{
String url = "jdbc:odbc:erp";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,"sa","");
String sql = "select * from hys_lshy";
System.out.println("native form:"+connection.nativeSQL(sql));
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
System.out.println("zbc:"+rs.getString(1));
connection.close();
}
catch(Exception ex)
{
System.err.println("a problem:"+ex);
}
}
}
上面的代码在执行时,出现下列错误:
native form:select * from hys_lshy
java.sql.SQLException:[Microsoft][ODBC Driver Manager] Invalid cursor
state
我刚学习Java,还盼大家的相扶!
import java.sql.*;
class Database{
public static void main(String args[])
{
String url = "jdbc:odbc:erp";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,"sa","");
String sql = "select * from hys_lshy";
System.out.println("native form:"+connection.nativeSQL(sql));
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
System.out.println("zbc:"+rs.getString(1));
connection.close();
}
catch(Exception ex)
{
System.err.println("a problem:"+ex);
}
}
}
上面的代码在执行时,出现下列错误:
native form:select * from hys_lshy
java.sql.SQLException:[Microsoft][ODBC Driver Manager] Invalid cursor
state
我刚学习Java,还盼大家的相扶!
|
import java.sql.*;
class Database{
public static void main(String args[])
{
String url = "jdbc:odbc:erp";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,"sa","");
String sql = "select * from hys_lshy";
System.out.println("native form:"+connection.nativeSQL(sql));
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
//添加
if(rs.next()) {
System.out.println("zbc:"+rs.getString(1));
}
rs.close();
statement.close();
//完
connection.close();
}
catch(Exception ex)
{
System.err.println("a problem:"+ex);
}
}
}
class Database{
public static void main(String args[])
{
String url = "jdbc:odbc:erp";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection(url,"sa","");
String sql = "select * from hys_lshy";
System.out.println("native form:"+connection.nativeSQL(sql));
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(sql);
//添加
if(rs.next()) {
System.out.println("zbc:"+rs.getString(1));
}
rs.close();
statement.close();
//完
connection.close();
}
catch(Exception ex)
{
System.err.println("a problem:"+ex);
}
}
}
|
对,如果下一条有记录,则返回TRUE。
初始使指向第一条记录之前。
初始使指向第一条记录之前。
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。