GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HackerRank/insertData.java at master · addhari/HackerRank

Expand file tree

/

insertData.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
62 lines (45 loc) · 1.82 KB
/

insertData.java

Copy path

File metadata and controls

62 lines (45 loc) · 1.82 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package hackerrank;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class insertData {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost/social_trade";
static final String USER = "root";
static final String PASS = "ron";
static Statement stmt = null;
public static void main(String[] args) {
try{
BufferedReader br = null;
FileReader fr = null;
Connection conn = null;
String sCurrentLine;
String q="";
for(int i=6;i<10;i++)
{
br = new BufferedReader(new FileReader("C:\\Users\\Harry\\Documents\\data\\"+i+".csv"));
String[] d=new String[5];
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
stmt = conn.createStatement();
while ((sCurrentLine = br.readLine()) != null) {
d=sCurrentLine.split(",");
if(d.length==4)
{
q="INSERT INTO data " +"VALUES ("+d[0]+", '"+d[1]+"')";
new insert(q).start();
Thread.sleep(10);
}
}
System.out.println("Done"+i);
br.close();
new File("C:\\Users\\Harry\\Documents\\data\\"+i+".csv").delete();
}
}catch(Exception se){
se.printStackTrace();
}
}
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.