473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Data Type Mismatch the criteria expression

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
1 2216
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

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

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

Similar topics

1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
4
by: N J | last post by:
Hi, CurrentDb.Execute "Update tblDelayedOrders Set DELAYED = True Where ID = " & Me.txtOrderNumber & ";", dbfailonerror Me.StatusListBox.AddItem "ORDER # " & Me.txtOrderNumber & " MARKED AS...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: technocraze | last post by:
Hi guys, Implementations application & programming environ MS Acess + Visual Basic Table fields Serialno (pk) - Auto number StudentId - text Course - text intake - number
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
1
by: DC | last post by:
Any idea why this code would cause a error? The SQL that gets executed seems to be (using record 1132 as an example) DELETE FROM user_table WHERE ID = '1132'; And the value of...
2
by: tmoon3 | last post by:
Hello, This must be a simple mistake, but for some reason I cannot seem to get around it. I am simply trying to create a report of all employees that have a date filled in in a training column...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.