i have now tried this
program using buffer reader
where the input is saved in the string ss
and then passed to the sql statement...
but iam gettin an exception ..saying too few parameters..
please help me...iam struck with this for a long time...
import java.io.*;
import java.sql.*;
class buffer1
{
public static void main(String ar[])
throws IOException
{
BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) );
String line1;
// declaration of input Strings
int first;
// declaration of int variables
System.out.println("Enter first Name:");
line1 = stdin.readLine();
//first = Integer.parseInt( line1 ); // convert line1 to first int
System.out.println("The name is " +line1);
try {
// Step 1: Load the JDBC driver.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc
dbc:mayank";
Connection conn = DriverManager.getConnection(url,"","");
Statement st = conn.createStatement();
//these two statements does not execute durin the program
int m;
//String k= "line1";
m= st.executeUpdate("insert into mayank(class) values(line1) ");
ResultSet rs;
rs= st.executeQuery("select class,name from mayank ");
conn.commit();
while(rs.next())
{
String n= rs.getString("name");
String c = rs.getString("class");
System.out.println(n + " " + c);
}
}
catch (Exception e)
{
e.printStackTrace();
/*System.err.println("Got an exception! ");
System.err.println(e.getMessage());
*/
}
}
}