java连oracle问题

来源:百度知道 编辑:UC知道 时间:2024/05/04 15:31:49
import java.sql.*;
public class InsertTestData {
public static void main(String[] args){
String sql = "";
String classid[] = new String[3];
classid[0] = "20"; classid[1] = "30"; classid[2] = "40";
try{
new oracle.jdbc.driver.OracleDriver();
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:buaa108","scott","tiger");
sql = "insert into test_question_lib values(test_seq_question.nextval,?,?,?,?,?,?,?,?)";

PreparedStatement stmt=conn.prepareStatement( sql );
for(int i=0; i<500; i++) {
// 设置题型
stmt.setInt(1,(int) (Math.floor(2*Math.random()) + 1));
stmt.setString(2,classid[(int)(Math.floor(3*Math.random()))]);
stmt.setString(3,"Test question " + i);
stmt.setString(4,"selection 1");
stmt.setString(5,"selection 2");
stmt.

你找到的是不是Test question 1 --- Test question 500
你不会看到其它的列去了啊

看起来是没问题,我也找不出来错在哪

可能是没有提交~

你再换多一个JDK来运行下吧,我觉得不是程序的问题