[英]how to upload data into oracle from csv file where client and server are on different physical systems using java
I want to upload data from csv file on client to oracle database on server which is physically on different machine using java. 我想将客户端上的csv文件中的数据上传到服务器上的oracle数据库,该服务器实际上是使用Java在另一台计算机上。 I searched online for solutions but all solutions are working only for the case where both client and server are on same machine. 我在线搜索了解决方案,但所有解决方案仅在客户端和服务器都在同一台计算机上的情况下才有效。
Please help 请帮忙
String temp = ((System.getenv("USERPROFILE"))+("\\Documents\\"));
String path = "";
path = temp.replace("\\", "\\\\");
path = path + "upload.csv";
//System.out.println(path);
Connection connection = MyConnection.getConnection();
String loadQuery = "LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE documents FIELDS TERMINATED BY ','" + " LINES TERMINATED BY '\n' ( Customer, address1 )";
//System.out.println(loadQuery);
Statement stmt = connection.createStatement();
stmt.execute(loadQuery);
This path works if the server and client are on same machine, how to modify this when server and client are on different machine ? 如果服务器和客户端在同一台计算机上,则此路径有效,当服务器和客户端在不同计算机上时,如何修改此路径?
If I understand well you have 如果我了解你
And you need to save the data from csv to oracle. 并且您需要将数据从csv保存到oracle。 Correct? 正确? If so this is a standard java application with I/O to read the file and JDBC access to a remote database. 如果是这样,这是一个具有I / O的标准Java应用程序,用于读取文件和对远程数据库的JDBC访问。
Basically here are the steps: 基本上是以下步骤:
1) Open the csv
2) Open a database connection
3) Read a row from csv and convert it to an object (if using JPA)
4) Save the object
5) Go to the next row until finish
6) Commit and close all resources
To access a remote database simply substitute 127.0.0.1 (or localhost) from the url connection with the ip of the remote database. 要访问远程数据库,只需将URL连接中的127.0.0.1(或localhost)替换为远程数据库的ip。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.