java调用DB2的问题
import java.sql.*;
public class test{
public test() {
}
public static void main(String[] args) {
System.out.println("helloworld");
try{
Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
String url = "jdbc:db2://192.168.70.106:5000/test";
System.out.println("helloworld,adsfaaaaddddddd");
//test为你的数据库名
String user = "db2admin";
String password = "db2admin";
Connection conn = DriverManager.getConnection(url, user, password);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql = "select * from test";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
}catch(Exception ex)
{
System.out.println("helloworld,法dfafd");
}
}
}
为什么我的 System.out.println("helloworld,adsfaaaaddddddd");不执行,而在异常处执行了 System.out.println("helloworld,法dfafd");
Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();应该没问题呀?
清帮我看看问题出在哪里?