No value specified for parameter X in log

org.postgresql.util.PSQLException: No value specified for parameter 7. 
    	at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:146) 
    	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:183) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350) 
    	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:304) 
    	at sun.reflect.GeneratedMethodAccessor240.invoke(Unknown Source) 
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    	at java.lang.reflect.Method.invoke(Method.java:585) 
    	at com.servoy.j2db.persistence.datasource.p.invoke(Unknown Source) 
    	at $Proxy1.executeUpdate(Unknown Source) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:207) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:207) 
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:207) 
    	at com.servoy.j2db.dataprocessing.SQLEngine.performUpdates(Unknown Source) 
    	at sun.reflect.GeneratedMethodAccessor242.invoke(Unknown Source) 
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    	at java.lang.reflect.Method.invoke(Method.java:585) 
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294) 
    	at sun.rmi.transport.Transport$1.run(Transport.java:153) 
    	at java.security.AccessController.doPrivileged(Native Method) 
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:149) 
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) 
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) 
    	at java.lang.Thread.run(Thread.java:613)

Hi all,

we are still seeing some of these messages after upgrading to 3.5.7. I have switched on logging in PostgreSQL try to understand what is going on, but nothing is getting logged. If send a bad query from a 3rd party tool, it is logged straight away.

Any ideas?

PostgreSQL 8.2.x, latest 8.3 driver.
java.vm.version=1.5.0_06-68
os.name=Mac OS X
os.version=10.4.7
os.arch=i386

Mac OS X Clients…

Hi Christian,

Do you use custom SQL in your code ? Like with datasets?
If so do you also have exception checking coded in?
Like with datasets you can do this:

var ds = databaseManager.getDataSetByQuery(sServer, sQuery, aParams, -1);
if ( ds.getExceptionMsg() ) {
	// Database exception occured.
	application.ouput("MyMethodName: " + ds.getExceptionMsg() );
} else {
	// do your thing
}

When you don’t do this exception checking then you never get any errors othere than in the servoy log.
But it’s indeed weird that it doesn’t show up in the PostgreSQL log.

Hope this helps.

Hope this helps.

Hi Robert,

I’m doing a lot of custom queries, but if something goes wrong the SQL statement normally get logged, so these are easy to track down.

In the error message I see

at com.servoy.j2db.dataprocessing.SQLEngine.performUpdates(Unknown Source)

Does this mean Servoy is trying to save and fails?

I think you don’t see anything in the Postgres log because that query probably never reaches the database. It is “kicked out” by the JDBC driver already. The error says that a parameter (argument) is missing (you have 7 question marks, but only 6 values). I have seen this error many times, but it was always a custom query that caused the problem.

HI Patrick,

Thanks for confirming what I have suspected – the query never reaches the database.

In this case it would very useful if Servoy put a little more debugging information in the log…

The exception is thrown from jdbc driver, we only catch it and display it in the log. So we cannot make this error more user friendly. What we could do is to make some of these checks ourselves, but this would duplicate what the driver does, so I don’t think we would want that …

Even if you can’t show the query or params, it would be of great help to understand which method or form or event the query is fired from – at the moment I have no idea where to look.

3.5.8 will give you the sql and its parameters for such update queries that where failing.

are you using dbidentities as your pk sequences?

because it could be that you set a db identity pk of a new record somewhere to another record
and if that record is saved first before the new record above error will happen.

i am also currently fixing that that the order of which records are saved depends on the the usage of a new records pk in data in other records, so in this case the new record will be saved first before other records will be saved.

Christian,

There is another situation that could cause this error.
If you are using db identity columns and are referring to the pk of a record that has not been saved yet (so the pk value is not known yet), servoy currently skips the value in the prepared statement which could cause the driver to complain about missing parameters.

I have fixed this for next release to log a more descriptive error.

Rob