0% found this document useful (0 votes)
8 views1 page

Import CSV to Database with Java

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Import CSV to Database with Java

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

From excel sheet to database table:

===================================

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class CSVReader {

public static void main(String[] args) {


int k=0;
try {
[Link]("[Link]");
Connection con=[Link]
("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement ps=[Link]
("insert into csvdata values(?,?,?,?,?)");
FileInputStream fis=new FileInputStream
("C:\\Users\\DELL\\Downloads\\MOCK_DATA.csv");
Scanner s=new Scanner(fis);
[Link]();
while([Link]())
{
String str[]=[Link]().split(",");
for(int i=1;i<=5;i++)
{
[Link](i, str[i-1]);
}
}
if(k>0)
[Link]("data inserted.....");
}
catch (Exception e) {

You might also like