PDA

Click to See Complete Forum and Search --> : [RESOLVED] Please help with preparedstatement


Nitesh
Aug 4th, 2008, 07:29 AM
Hi Guys, please help me

I have this code inside a loop:

String f_supplier = nextLine[7];
long Sid = 0;

if (!f_supplier.equals(""))
{

try
{
stSupplier = ITdb.prepareStatement("SELECT OurID FROM Mapping WHERE MapName = ? AND Active=1");
rsSupplier = stSupplier.executeQuery();
stSupplier.setString(1,f_supplier);

if (rsSupplier.next()) {
Sid = rsSupplier.getLong("OurID");

//if no record found
} else {

Sid = 0;

} // if
}catch (exception e) {
e.printStackTrace();
}

}else{

Sid=0;
}

but I get this error:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3149)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:216)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(JdbcOdbcPreparedStatement.java:91)
at BusbyFTP.doImport(BusbyFTP.java:126)
at BusbyFTP.doWork(BusbyFTP.java:51)
at Job.doWork(Job.java:81)
at JobPane.btnRunNowActionPerformed(JobPane.java:148)
at JobPane.access$500(JobPane.java:11)
at JobPane$6.actionPerformed(JobPane.java:139)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Nitesh
Aug 4th, 2008, 07:49 AM
im so stupid, I had these two lines the wrong way around:

rsSupplier = stSupplier.executeQuery();
stSupplier.setString(1,f_supplier);

the problem seems fixed now:)