create and insert values using mysql JDBC
- by S.PRATHIBA
Hi all,
I have the sample code.
public void UpdateTable1()
{
for(int t=0;t<20;t++)
{
if(consumer==1 && number==1 && provider1==31 && feedback==1)
{
try{
Class.forName(driverName);
con = DriverManager.getConnection(url+dbName,"root","mysql");
try
{
Statement st = con.createStatement();
int val = st.executeUpdate("INSERT Consumer1 VALUES ("+31+","+"'Printer'"+", "+1+" "+")");
System.out.println("1 row affected");
}
catch (SQLException s)
{
System.out.println("SQL statement is not executed!");
}
con.close();
}
I want to insert the same set of values(31,printer,1) into the table consumer2,consumer3.Is it possible without using another try catch statements...Please help me.