Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC jdbc sql exception.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ravibabu
jdbc sql exception.
2 Answer(s)      3 years and 2 months ago
Posted in : JDBC


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)


Advertisement
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 exception
jdbc 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
SQL Exception
SQL 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&
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
Java sql Exception
Java sql Exception  difference between sql exception class and sql warning class
jdbc adapter exception - JDBC
jdbc 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 ResultSet
SQL 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 - JDBC
key constraints in SQL server  Does SQL have a FOREIGN KEY constraints in a Table
sql - JDBC
SQL joins queries   Hi, can anyone give me the couple of SQL joins queries with examples
sql-jdbc
sql-jdbc  how to execute select query using prepared statement
sql exception - JSP-Servlet
sql 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
sql - JDBC
://www.roseindia.net/jdbc/jdbcconnectivity.shtml You will find the solution. Thanks
Sql - JDBC
SQL 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
exception at runtime - JDBC
exception 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
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
".txt" to sql with JDBC
".txt" to sql with JDBC  how to insert ".txt" into sql result[BLOB] with JDBC
JDBC Exception
JDBC Exception      ... the execution of program. Exception Occurred in JDBC Connectivity when a connection... with ExampleThe Tutorial illustrates an example from JDBC Exception
jdbc & sql related project - JDBC
jdbc & 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
Connectivity with sql in detail - JDBC
Connectivity 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
creating jdbc sql statements - JDBC
creating 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 - JDBC
SQL 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 - JDBC
JDBC 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
sql query - JDBC
sql query  I need a SQL query to add data into database
Connections with MicroSoft SQL - JDBC
Connections 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
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
Connectivity with sql in detail - JDBC
Connectivity with sql in detail  Sir/Madam, I am unable to connect the sql with Java. Please tell me in detail that how to connect. Thankyou
java-sql - JDBC
java-sql  how to convert excel file into sql database usin java programming
Help on JDBC and my SQL 5 database - JDBC
Help 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 query
JDBC- 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 query
JDBC- 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
Advertisements
 

 

 

DMCA.com