import java.io.*; import java.sql.*;
public class ImportToOracle { public static void main(String[] args) { String database_name; String dataset; String dataset_description; String dataset_experiment_type; String dataset_maximum_probes; String dataset_organism; String dataset_title; String dataset_update_date; String dataset_value_type; String sDriver = "oracle.jdbc.driver.OracleDriver"; String sURL = "jdbc:oracle:thin:@211.69.192.178:1521:bio"; String sUsername = "geo"; String sPassword = "huangjing"; try { BufferedReader in = new BufferedReader(new FileReader("C:\\java\\Table\\Data.txt")); Class.forName(sDriver);//connect to database Connection conn = DriverManager.getConnection ( sURL, sUsername, sPassword ); System.out.println("connection succeed"); String sql = "insert into Dataset values(?,?,?,?,?,?,?,?,?)"; PreparedStatement pstmt = conn.prepareStatement(sql); database_name = in.readLine(); dataset = in.readLine(); dataset_description = in.readLine(); dataset_experiment_type = in.readLine(); dataset_maximum_probes = in.readLine(); dataset_organism = in.readLine(); dataset_title = in.readLine(); dataset_update_date = in.readLine(); dataset_value_type = in.readLine(); in.readLine(); while(database_name != null) { pstmt.setString(1,database_name); pstmt.setString(2,dataset); pstmt.setString(3,dataset_description); pstmt.setString(4,dataset_experiment_type); pstmt.setString(5,dataset_maximum_probes); pstmt.setString(6,dataset_organism); pstmt.setString(7,dataset_title); pstmt.setString(8,dataset_update_date); pstmt.setString(9,dataset_value_type); database_name = in.readLine(); dataset = in.readLine(); dataset_description = in.readLine(); dataset_experiment_type = in.readLine(); dataset_maximum_probes = in.readLine(); dataset_organism = in.readLine(); dataset_title = in.readLine(); dataset_update_date = in.readLine(); dataset_value_type = in.readLine(); in.readLine(); } conn.close(); in.close(); } catch(SQLException ex) { while(ex!=null) { ex.printStackTrace(); ex=ex.getNextException(); } } catch(IOException ex) { ex.printStackTrace(); } } } 编译说unreported exception java.lang.ClassNotFoundException;must be caught or declared to be thrown Class.forName(sDriver);//connect to database 哪位大虾指点一下