File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Data Type in criteria expression unacceptable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Data Type in criteria expression unacceptable" Watch "Data Type in criteria expression unacceptable" New topic
Author

Data Type in criteria expression unacceptable

Donna Harrington
Ranch Hand

Joined: Aug 08, 2003
Posts: 31
Hey guys,
When i run my application i get this error:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Datentypen in Kriterienausdruck unvertr�glich.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3065)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
at displayCustDetails.showDetails(displayCustDetails.java:116)
at displayCustDetails.actionPerformed(displayCustDetails.java:165)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5093)
at java.awt.Component.processEvent(Component.java:4890)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3598)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3439)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1585)
at java.awt.Component.dispatchEvent(Component.java:3439)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

The error is translated in english: Datatype in criteria expression unacceptable.
Does anybody know what this is? is it my SQL query?
Thanx people.
Here's the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;
import java.sql.*;
public class displayCustDetails extends JPanel implements ActionListener {

JPanel p1, custOpt, cards, box;
CardLayout cl;
JLabel newLabel;
JButton searchCust,modifyCust,deleteCust;
String custId,cSex,cFname,cLname,cDob,cAddress,cContactNo;
JTextField custIdTF ,custSexTF,custFNameTF ,custLNameTF,custDateOfBirthTF ,custAddressTF,custContactNumberTF;

public displayCustDetails(CardLayout cl, JPanel p) {//Constructor for add employee
setSize(500,500);
this.cl = cl;
cards = p;


box = new JPanel();
box.setSize(200,200);
p1 = new JPanel();
p1.setLayout(new GridLayout(0,2));
JLabel customerIdLabel = new JLabel("Customer Id number:");
//JLabel custIdLabel = new JLabel(" ");
JTextField custIdTF=new JTextField();
custIdTF.setOpaque(false);
p1.add(customerIdLabel);
p1.add(custIdTF);

JLabel sexLabel = new JLabel("Sex");
JTextField custSexTF=new JTextField();
p1.add(sexLabel);
p1.add(custSexTF);


JLabel custFNameLabel = new JLabel("First Name");
JTextField custFNameTF=new JTextField();
p1.add(custFNameLabel);
p1.add(custFNameTF);
JLabel custLNameLabel = new JLabel("Last Name");
JTextField custLNameTF=new JTextField();
p1.add(custLNameLabel);
p1.add(custLNameTF);

JLabel cDateOfBirthLabel = new JLabel("Date of Birth");
JTextField custDateOfBirthTF=new JTextField();
p1.add(cDateOfBirthLabel);
p1.add(custDateOfBirthTF);
JLabel cAddressLabel = new JLabel("Address");
JTextField custAddressTF=new JTextField();
p1.add(cAddressLabel);
p1.add(custAddressTF);

JLabel cContactNumberLabel = new JLabel("Contact Number");
JTextField custContactNumberTF=new JTextField();
p1.add(cContactNumberLabel);
p1.add(custContactNumberTF);

JButton modifyCust = new JButton("Modify");
//modifyCust.addActionCommand("Modify");
modifyCust.addActionListener(this);
p1.add(modifyCust);


JButton clearCust = new JButton("Clear");
//clearCust.addActionCommand("Clear");
clearCust.addActionListener(this);
p1.add(clearCust);

JButton deleteCust = new JButton("Delete");
//deleteCust.addActionCommand("Delete");
deleteCust.addActionListener(this);
p1.add(deleteCust);

JButton backButton =new JButton("Main Menu");
backButton.setActionCommand("pic");
backButton.addActionListener(this);
p1.add(backButton);


add(p1);

}

public void showDetails(){
try{
Connection conn;
conn = DriverManager.getConnection("jdbc dbc:acidmenuDatabase","","");
Statement statement = conn.createStatement();
System.out.println(custId);
ResultSet rs = statement.executeQuery("SELECT custId, cSex, cFname, cLname, cDob, cAddress, cContactNo FROM customer WHERE custId ='"+ custId +"';") ;

if (rs.next() )
{
custIdTF.setText(rs.getString("custId"));
custSexTF.setText(rs.getString("cSex"));
custFNameTF.setText(rs.getString("cFname"));
custLNameTF.setText(rs.getString("cLname"));
custDateOfBirthTF.setText(rs.getString("cDob"));
custAddressTF.setText(rs.getString("cAddress"));
custContactNumberTF.setText(rs.getString("cContactNo"));
}


}

catch(Exception e){
System.err.println("Problems connecting to database");
e.printStackTrace();
return;
}
}
public void connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Error creating class: "+e.getMessage());
e.printStackTrace();
return;
}
}

public void actionPerformed(ActionEvent e) {

String command = e.getActionCommand();
cl = (CardLayout)(cards.getLayout());
cl.show(cards,command );
System.out.println(command);
connect();

custId=searchCustomer.getCustomerId();
System.out.println(custId);
showDetails();

}
}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

The exception happens when you're executing the query. You've not shown us the database schema, but my guess is that custId is not a CHAR column in the database; maybe it's an INTEGER? You've written a WHERE clause that implies the column is character data because the value it's being compared to is in quotes, but it looks like the database can't compare this column directly to a string.


[Jess in Action][AskingGoodQuestions]
Donna Harrington
Ranch Hand

Joined: Aug 08, 2003
Posts: 31
Thanx for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data Type in criteria expression unacceptable