将txt的内容按条读出,然后插入数据库不就OK了吗~~~

解决方案 »

  1.   

    在oracle 数据库中写一个存储过程来实现,用JAVA调用。
    做过,可以实现的,
    不紧可以导入,还可以导出
      

  2.   

    longrenrex(菜菜龙) ,怎么写?
      

  3.   

    先用fileStream读入文件
    根据行解析数据,以空格或TAB为分割(文件需要固定格式)
    写入一个info 结构的class
    然后使用JDBC将info数据循环插入ORACLE中对应的表的数据项就行了具体代码不写了。。
      

  4.   

    PreparedStatement提供下面的函数可以用于你的问题:setBinaryStream(int parameterIndex, InputStream x, int length) 
              Sets the designated parameter to the given input stream, which will have the specified number of bytes.
      

  5.   

    你应该看一看core java 2 volume I 第12章,core java 2 volume II 第4章,那里有答案。
      

  6.   

    package test;import java.io.*;
    import DB.OracleDB;public class TxtToDB {
        public static void doit(){
            String path = System.getProperty("user.dir");
            File file = new File(path + File.separator + "info.txt");  
            try{
                BufferedReader in =
                    new BufferedReader(
                    new FileReader(file));
                String s;
                int id = 0;
                while ( (s = in.readLine()) != null) {
                    String issue = "", number = "";
                    String[] str = s.split(" ");
                    if(str == null || str.length < 2){
                        continue; //丢弃不完整的数据
                    }
                    System.out.println(str[0] + "    " + str[1]);
                    String sql = "insert into mytest(id, name, num) values(" + id++ + ", '" + str[0] + "', '" + str[1] + "')";
                    OracleDB db = new OracleDB();
                    db.DBConn();
                    db.createStatement();
                    db.update(sql);
                    db.DBEnds();
                }
                in.close();
            }catch(IOException e){
                e.printStackTrace();
            }
            
        }
        public static void main(String[] args) {
            doit();
        }
    }