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



Home Answers Viewqa JDBC jdbc sql exception.

Have Programming Question? Ask it here!
 
 
 


ravibabu
jdbc sql exception.
2 Answer(s)      2 years and 11 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
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 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&
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
SQL joins queries   Hi, can anyone give me the couple of SQL joins queries with examples
sql - JDBC
key constraints in SQL server  Does SQL have a FOREIGN KEY constraints in a Table
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
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
".txt" to sql with JDBC
".txt" to sql with JDBC  how to insert ".txt" into sql result[BLOB] with JDBC
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
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
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
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
This Query is no working in sql developer it is giving Ora-0933 exception SQL command not properly ended exception
This Query is no working in sql developer it is giving Ora-0933 exception SQL command not properly ended exception  SELECT * from employees ORDER BY first_name limit 0,10;   Hi Friend, Please clarify your problem
SQL STATEMENT in JDBC in NETBEANS IDE
SQL 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
upload SQL BLOB and CLOB - JDBC
upload SQL BLOB and CLOB  Please explain upload SQL BLOB and CLOB
Reflection api :Invocation target exception - JDBC
Reflection api :Invocation target exception   Am using a function... it,but it throws a class not found : oracle.jdbc.driver.oracledriver exception in Invocation target Exception .How to resolve
UNICODE or SQL statement issue - JDBC
UNICODE 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
DataBase connectivity in java with Microsoft sql server2000 - JDBC
DataBase connectivity in java with Microsoft sql server2000  How i can achieve database connectivity with Microsoft sql server2000 in my java source code
Getting the Records in PL/SQl between Date Ranges - JDBC
Getting the Records in PL/SQl between Date Ranges  Getting the records Between the Dates in PL/SQL Database by using JDBC and display through JSP
Database connection sql server 2005 - JDBC
Database connection sql server 2005  Hi all i am developing an application in struts and i need to connect database for that application using sql server 2005.. can anyone tell me how to make database connection ..plz help me
exception
exception  wHEN RUNTIME EXCEPTION CLASS IS SUB OF EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED EXCEPTION
exception
exception  Identify the reason for SQLException exception, which..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost..."); ps.executeUpdate(); } catch(Exception e
JDBC Batch Example With SQL Insert Statement
JDBC Batch Example With SQL Insert Statement: In this tutorial, we are discuss about insert SQL statement with the jdbc batch. First of all, we...;com.mysql.jdbc.Driver"); connection = DriverManager.getConnection ("jdbc
JDBC Batch Example With SQL Update Statement
JDBC Batch Example With SQL Update Statement: In this tutorial, we are discuss about update SQL statement with the jdbc batch. Now we will create a java...;com.mysql.jdbc.Driver"); connection = DriverManager.getConnection( "jdbc:mysql
exception
exception  chek in and check out exception in java   Please visit the following link: Checked and Unchecked Exception
JDBC Batch Example With SQL Select Statement
JDBC Batch Example With SQL Select Statement: In this example, we are discuss about SQL select statement with JDBC batch process. We will create SQL...;    static final String url = "jdbc
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
Advertisements
 

 

 

DMCA.com