
import java.sql.*;
import java.io.*; class InsertEx { public static void main(String args[])throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ora","system","tiger"); Statement stmt=con.createStatement(); DataInputStream din=new DataInputStream(System.in); while(true) { System.out.println("Enter Employee number"); String s=din.readLine(); int no=Integer.parseInt(s); System.out.println("Enter Employee name"); String name=din.readLine(); System.out.println("Enter Employee salary"); s=din.readLine(); Float sal=Float.parseFloat(s); System.out.println("Enter Employee address"); String addr=din.readLine(); int count=stmt.executeUpdate("insert into myemp values("+no+",'"+name+",'"+sal+",'"+addr+"')"); if(count>0) System.out.println("Insert record successfully"); else System.out.println("record not Insert"); System.out.println("enter another record[yes/no]:"); String choice=din.readLine(); if(!choice.equalsIgnoreCase("yes")); break; } } } Error is:
E:>javac InsertEx.java Note: InsertEx.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
E:>java InsertEx Enter Employee number 1 Enter Employee name ravi Enter Employee salary 9000 Enter Employee address hyd Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC driver for Or acle][Oracle]ORA-00917: missing comma at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source) at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source) at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source) at InsertEx.main(InsertEx.java:23)

import java.io.*;
import java.sql.*;
class InsertEx{
public static void main(String args[])throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:student","","");
Statement stmt=con.createStatement();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
boolean status=false;
do{
System.out.println("Enter Employee number");
int no=Integer.parseInt(br.readLine());
System.out.println("Enter Employee name");
String name=br.readLine();
System.out.println("Enter Employee address");
String addr=br.readLine();
System.out.println("Enter Employee salary");
int sal=Integer.parseInt(br.readLine());
int count=stmt.executeUpdate("insert into employee(empid,name,address,salary) values("+no+",'"+name+"','"+addr+"',"+sal+")");
if(count>0)
System.out.println("Insert record successfully");
else
System.out.println("record not Insert");
System.out.println("enter another record[yes/no]:");
String choice=br.readLine();
if(!choice.equalsIgnoreCase("yes")){
status=true;
}
}
while(!status);
}
}

For the above code, do the following:
Follow these steps:
1)Go to the start>>Control Panel>>Administrative Tools>> data sources.
2)Click Add button and select the driver Microsoft Access Driver(*.mdb).
3)After selecting the driver, click finish button.
4)Then give Data Source Name and click ok button.
5)Your DSN will get created.
We have a dsn named 'student'.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.