jdbc sql exception.
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)
View Answers
August 27, 2011 at 1:03 PM
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);
}
}
August 27, 2011 at 2:47 PM
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'.
Related Tutorials/Questions & Answers:
jdbc sql exception.jdbc sql exception. 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 jdbc odbc sql server exceptionjdbc odbc
sql server exception Hi,
I am trying to use
sql server with java
jdbc odbc but I am getting this
exception
java.sql.SQLException: [Microsoft][
SQL Server Native Client 10.0][
SQL Server]Incorrect syntax near '@P1
Advertisements
Enhanced SQL Exception Handling
Enhanced
SQL Exception Handling
5. Enhanced
SQL Exception Handling:
A lot of improvement has been done regarding
Exception handling
in the following fields:
Iterable
SQL Exception SQL ExceptionSQL Exception I want stores data in to the databse table but it can't be stores it shows an error
about
sql exception.
blackberry.html
<...("
jdbc:odbc:asset");
String Qry = "INSERT INTO blackberry&
Java sql ExceptionJava
sql Exception difference between
sql exception class and
sql warning class
jdbc adapter exception - JDBCjdbc adapter exception Through
JDBC, I connected to MySQL Server... = FOREIGN_KEY_CHECKS = 0" to
JDBC URL( i.e., "
jdbc:mysql://MyHost/myDB").Modified URL is:
"
jdbc:mysql://MyHost/myDB?sessionVariables = FOREIGN_KEY_CHECKS = 0
SQL exception, Exhausted ResultSetSQL exception, Exhausted ResultSet javax.servlet.ServletException: java.sql.SQLException: Exhausted Resultset
iam getting this error messege whenever i run my code. what would be the possible reasons
sql exception - JSP-Servletsql exception Dear sir ,
I am working in a web-based project, In my system it is working fine but at client side getting the following
exception so how to resolve this help me...
java.sql.SQLException: ORA-28231
exception at runtime - JDBCexception at runtime while i executing this source code:-
import...;
String url = "
jdbc:mysql://localhost:3306/";
String dbName = "bank";
String... (
Exception e)
{
e.printStackTrace();
}
}
}
i got an
exception JDBC Exception
JDBC Exception
The
Exception are the set of condition that occurred when an abnormal... the
execution of program.
Exception Occurred in
JDBC Connectivity when a
connection
sql - JDBCkey constraints in
SQL server Does
SQL have a FOREIGN KEY constraints in a Table
sql - JDBCSQL joins queries Hi, can anyone give me the couple of
SQL joins queries with examples
java runtime exception - JDBC.");
Connection con = null;
String url = "
jdbc:mysql://localhost:3306...");
}
catch (
Exception e)
{
e.printStackTrace();
}
}
}
i got an
exception that classnotfoundexception . how can i remove
sql-jdbcsql-jdbc how to execute select query using prepared statement
sql - JDBC://www.roseindia.net/
jdbc/jdbcconnectivity.shtml
You will find the solution.
Thanks
Sql - JDBCSQL Statement and prepared statement What is Statement and prepared statement in SQL Statement and prepared statement are the interfaces declared in JAVA.SQL.While you connecting to a database these are required.If
Connectivity with sql in detail - JDBCConnectivity with
sql in detail Sir/Madam,
I am unable to connect the
sql with Java. Please tell me in detail that how to connect...;
String url = "
jdbc:mysql://localhost:3306/";
String dbName
jdbc & sql related project - JDBCjdbc &
sql related project code using
jdbc,odbc,swing,MySql classes to create front-end of any
jdbc that allows the user to select any database from a list and execute any
sql query related to the selected database e.g
creating jdbc sql statements - JDBCcreating
jdbc sql statements I had written the following program...=DriverManager.getConnection("
jdbc:odbc:second");
stmt=con.createStatement..."+rs.getString(2)+"\t"+rs.getFloat(3));
}
catch(
Exception e
SQL QUERY - JDBCSQL QUERY I m running a query using apache tomcat the
sql query is on adding an employee in the database whenever i click on add after inserting the values i am getting a java.lang.nullpointer
exception JDBC connection and SQL Query - JDBCJDBC connection and
SQL Query Hi,
I'm reading a all files one after the other in a directory in java. storing the values in an array of string each time. Now I'm trying to execute a query to insert those values into an oracle
Connections with MicroSoft SQL - JDBCConnections with MicroSoft SQL How to Connect Java and MS
SQL??
Actually i used below code i got SQLException and class not found...
import...;
Statement st = null;
ResultSet rs = null;
String url = "
jdbc My sql - JDBC,emp_vertical,emp_supervisor.
i need a
JDBC program with driver mangager... out.
i need insert and update queries. Hi friend,
For
JDBC...://www.roseindia.net/
jdbc/
jdbc-mysql/SelectRecords.shtml
http://www.roseindia.net/
jdbc java-sql - JDBCjava-sql how to convert excel file into
sql database usin java programming
Help on JDBC and my SQL 5 database - JDBCHelp on
JDBC and my
SQL 5 database Dear Sir,
I had create a statement for the
JDBC as shown below:
try... the connection
c = DriverManager.getConnection
("
jdbc:mysql
JDBC- SQL spatio-temporal queryJDBC-
SQL spatio-temporal query Any one give me a
JDBC sql query for my spatio temporal query?
Trajectory table
OBJID PLACE
7 H
8
Q
9 W
10... as shown in above. I want a spatio-temporal query using
JDBC-
SQL to retrieve
JDBC- SQL spatio-temporal queryJDBC-
SQL spatio-temporal query Any one give me a
JDBC sql query for my spatio temporal query?
Trajectory table
OBJID PLACE
7 H
8
Q
9 W
10... as shown in above. I want a spatio-temporal query using
JDBC-
SQL to retrieve
SQL STATEMENT in JDBC in NETBEANS IDESQL STATEMENT in
JDBC in NETBEANS IDE Iam using NETBEANS IDE. Iam developing a bank application. Using
JDBC in SERVLETS
For the withdraw function, "bal" and "ano" are user inputs when i wrote like,
st.executeQuery("UPDATE
UNICODE or SQL statement issue - JDBCUNICODE or
SQL statement issue Hi again............
I have got something new that...........
i was using MS Access as the database with my... nothing ......
I had also change my backhand to
SQL SERVER but retrieves same
exceptionexception wHEN RUNTIME
EXCEPTION CLASS IS SUB OF
EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED
EXCEPTION exceptionexception Identify the reason for SQLException
exception, which...");
Connection con = DriverManager.getConnection("
jdbc:mysql://localhost...");
ps.executeUpdate();
}
catch(
Exception e
exceptionexception chek in and check out
exception in java
Please visit the following link:
Checked and Unchecked
Exception exception arguments are not equalto two,throw a user defined
exception "invalid parameter
exception" ,otherwise display the two parameters.
Here is an example... is not equal to two then invalid parameter
exception is thrown ,otherwise display the two
JDBC4.0-SQL Exception Handling Enhancements categories of SQLException introduced in
JDBC 4.0:
SQL non-transient
exception
SQL... of the
SQLException is corrected. The new
exception classes that are added in
JDBC 4.0...: This
exception is thrown when a
previously failed
JDBC operation might be able
exceptionexception what is the use of catch block even though we have predefined
exception object
exceptionexception example for numberformat
exception
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
class NumberFormatExceptionEx...);
}
catch(
Exception e){
System.out.println(e
exception defined checked
exception ââ?¬Å?InvalidCharcterFoundExceptionââ?¬Â? and creater a block of codes that will handle the
exception