Hello
I have a problem when coding the statement
Code:
where mname, mail,tel are variables
which the user inputs them and stored in variables and then i want them to be stored in MS Access, everything is done successfully until it reached the previous statement
Here is the code
I have a problem when coding the statement
Code:
PHP:
stmt.execute("insert into Member values ('+mname+' ,'+mail+','+tel+')");
which the user inputs them and stored in variables and then i want them to be stored in MS Access, everything is done successfully until it reached the previous statement
Here is the code
PHP:
try {
System.out.println("Beginning Connection");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String accessFileName = "jdbc:odbc:Project";
String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
Connection con = DriverManager.getConnection( accessFileName);
Statement stmt = con.createStatement();
System.out.println("Connection done successfully");
stmt.execute("Create table Member(Name String,EMAIL String,Telephone String)");
System.out.println("Table Created");
System.out.println("Please, Enter the Member Name : ");
InputStreamReader istream = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (istream);
try{
String mname= (br.readLine());
System.out.println("Please, Enter the E-Mail Address : ");
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader bfr = new BufferedReader (isr);
try
{
String mail= (bfr.readLine());
try{
System.out.println("Please, Enter the Telephone number : ");
InputStreamReader ism = new InputStreamReader (System.in);
BufferedReader bb = new BufferedReader (ism);
String tel=String.valueOf(bb.readLine());
stmt.execute("insert into Member values ('+mname+' ,'+mail+','+tel+')");
System.out.println("Insertion has been completed");
stmt.execute(" select * from Member");
ResultSet rs=stmt.getResultSet();
if (rs != null)
while (rs.next()){
System.out.println("Name: "+rs.getString("Name")+ " E-MAIL: " + rs.getString("EMAIL")+" Telephone: "+rs.getString("Telephone"));
}
stmt.close();
con.close();
}
catch (IOException err)
{
System.out.println("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.println("Error in reading the numbers");
}
}
catch (IOException err)
{
System.out.println("Error in reading the numbers");
}
}
catch (Exception err) {err.printStackTrace();}
}