当前位置: 技术问答>java相关
help java中jdbc:odbc桥能否用prepareStatement???
来源: 互联网 发布时间:2015-05-03
本文导语: 初学java : java中jdbc:odbc桥能否用prepareStatement实现查询,怎么实现? 我的程序如下:!! String url = "jdbc:odbc:mmm"; Connection con; String query = "select COORD_X from MNSA_MSC_INFO where ICON_INDEX = ?";...
初学java :
java中jdbc:odbc桥能否用prepareStatement实现查询,怎么实现?
我的程序如下:!!
String url = "jdbc:odbc:mmm";
Connection con;
String query = "select COORD_X from MNSA_MSC_INFO where ICON_INDEX = ?";
PreparedStatement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
textBox.setText ("ClassNotFoundException: ");
textBox.setText(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"sa", "setup");
stmt = con.prepareStatement(query);
stmt.setInt(1,2);
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String s = rs.getString("COORD_X");
textBox.setText(s);
}
stmt.close();
con.close();
} catch(SQLException ex) {
textBox.setText("SQLException: " + ex.getMessage());
}
}
编译后出现 SQLException: Driver does not support this function!!!
如何解决???mmm是sql server 数据库!
谢谢!!
java中jdbc:odbc桥能否用prepareStatement实现查询,怎么实现?
我的程序如下:!!
String url = "jdbc:odbc:mmm";
Connection con;
String query = "select COORD_X from MNSA_MSC_INFO where ICON_INDEX = ?";
PreparedStatement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
textBox.setText ("ClassNotFoundException: ");
textBox.setText(e.getMessage());
}
try {
con = DriverManager.getConnection(url,
"sa", "setup");
stmt = con.prepareStatement(query);
stmt.setInt(1,2);
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String s = rs.getString("COORD_X");
textBox.setText(s);
}
stmt.close();
con.close();
} catch(SQLException ex) {
textBox.setText("SQLException: " + ex.getMessage());
}
}
编译后出现 SQLException: Driver does not support this function!!!
如何解决???mmm是sql server 数据库!
谢谢!!
|
修改如下:
stmt = con.prepareStatement(query);
stmt.setInt(1,2);
ResultSet rs = stmt.executeQuery();
stmt = con.prepareStatement(query);
stmt.setInt(1,2);
ResultSet rs = stmt.executeQuery();
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。