I know the simple method of adding one row into sql database using netbeans.
Here is that method:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/zeeshan",
"root","sHaNi97426");
Statement stmt = (Statement)conn.createStatement();
String insert = "INSERT INTO clients VALUES('"+hostname+"');";
stmt.executeUpdate(insert);
Now, I want to add multiple rows in sql database. For example, in the code given below:
Process p = Runtime.getRuntime().exec("tasklist.exe");
BufferedReader s = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s.readLine()) != null) {
System.out.print(s.readLine());
}
I want to add each line in sql till s.readLine() becomes null.
Kindly help me.