将txt的内容按条读出,然后插入数据库不就OK了吗~~~
解决方案 »
- 关于FckEdit。。
- java service 项目问题?
- 问个比较简单的问题??关于<jsp:useBean> bean 作用域的使用.
- 大文件想存成sqlserver数据库中的ntext或image,如何实现。谢谢
- 在线求教:jsp中获得当前时间的代码如何写?
- 我在使用RetoGuard混淆器时候遇到了下面的问题,请指教
- 请教一问题:jsp中作用"范围"(page, session, application)之间有什么区别?
- 我的公司现在要做一个WEB站点,要求用JSP和Oracle,请给我提个方案!
- 请教servlet调用bean的问题
- 大量请求导致数据出错
- 高手请进:请问如何读写本地的存有乱码的文本文件,在线等
- 求助!在Applet里面写框架结构~
做过,可以实现的,
不紧可以导入,还可以导出
根据行解析数据,以空格或TAB为分割(文件需要固定格式)
写入一个info 结构的class
然后使用JDBC将info数据循环插入ORACLE中对应的表的数据项就行了具体代码不写了。。
Sets the designated parameter to the given input stream, which will have the specified number of bytes.
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();
}
}