By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Data Type Mismatch the criteria expression

P: 1
Expand|Select|Wrap|Line Numbers
  1. package batch;
  2. import java.sql.*;
  3. /**
  4.  *
  5.  * @author Sikander
  6.  */
  7. public class Batch {
  8.  
  9.  
  10.     public static void main(String[] args)
  11.     {
  12.         String driver= "sun.jdbc.odbc.JdbcOdbcDriver";
  13.         String url= "jdbc:odbc:Database12";
  14.         String username="";
  15.         String password="";
  16.         ShowStudentTable(driver,url,username,password);
  17.     }
  18.  
  19.     private static void ShowStudentTable(String driver, String url, String username, String password) 
  20.     {
  21.         try {
  22.             Class.forName(driver);
  23.             Connection connection = DriverManager.getConnection(url,username,password);
  24.             connection.setAutoCommit(false);// Disables auto-commit
  25.             System.out.println("Student Data"+"\n"+"=========");
  26.             Statement statement= connection.createStatement();
  27.  
  28.             statement.addBatch("update Student set Name='bakhtawar' where id='1'");
  29.            statement.addBatch("update Student set Name='Komal' where id='2'");
  30.             statement.addBatch("update Student set Name='Santosh' where id='3'");
  31.  
  32.             statement.executeBatch();
  33.  
  34.             String query="SELECT ID,Name,Class,Marks FROM Student";
  35.             ResultSet resultSet= statement.executeQuery(query);
  36.  
  37.             while(resultSet.next())
  38.             {
  39.                 System.out.println(resultSet.getInt(1));
  40.                 System.out.println(resultSet.getInt(2));
  41.                 System.out.println(resultSet.getInt(3));
  42.                 System.out.println(resultSet.getInt(4));
  43.                 connection.commit();
  44.             connection.close();
  45.  
  46.             }
  47.  
  48.         }
  49.  
  50.         catch(ClassNotFoundException cnfe) 
  51.         {
  52.             System.err.println("Error loading driver: " + cnfe);
  53.         } 
  54.         catch(SQLException sqle) 
  55.         {
  56.             System.err.println("Error connecting: " + sqle);
  57.         }
  58.  
  59.     }
  60. }

So the error occured is that
run:
Student Data
=========
Error connecting: sun.jdbc.odbc.JdbcOdbcBatchUpdateException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
BUILD SUCCESSFUL (total time: 0 seconds)
Mar 28 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,347
Please use code tags when posting code.

What line is the error on?
Mar 28 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.