日期:2014-05-20  浏览次数:20836 次

jdbc连接数据报错
我在用jdbc连接oracle数据库时候报错。此处为源码:
public static void main(String[] args) {

String url = "jdbc:oracle:thin:@localhost:1521:NewDB";
String username = "scott";
String password = "syf12345";
String sql = "insert into users(username,password) values(?,?)";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, username,
password);
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "LiuWei");
pstmt.setString(2, "ilu");
pstmt.executeUpdate();
pstmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}

catch (ClassNotFoundException e) {

e.printStackTrace();
}

}
所用的驱动是ojdbc6.jar 执行程序报错:Could not find the main class 。Progra will exit
  
拜托各位前辈帮我这个新手菜鸟解决一下

------解决方案--------------------
晕,是找不到主类啦,就是找不到你的class与数据库无关
------解决方案--------------------
程序看上去是对的。
可能是类编译用的jdk版本高于运行时环境的JRE版本。
设为一样的试试
------解决方案--------------------
是LZ你的JDK版本不对
------解决方案--------------------
UnsupportedClassVersionError
探讨
是LZ你的JDK版本不对