Skip site navigation (1) Skip section navigation (2)

create tables and prepared statements with params

From: Enrique Rodríguez Lasterra <lasterra(at)javahispano(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: create tables and prepared statements with params
Date: 2006-09-13 17:10:23
Message-ID: (view raw or whole thread)
Lists: pgsql-jdbc
 get an error when i create a table using preparedstatement with some
parameters "?".

Is this a non standard function?

With JDBC 7.4 it runs prefectly but with 8.x no. With 8.x if i don't
use params the table is created without errors

Here is all the info.

Regards, Enrique


package test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

* DB
* @version 1.0
* @since 13-sep-2006
public class DB {
   public static void main(String[] args) {
       Connection connection = null;
       try {
           connection =
"canyamo-test", "canyamo-test");
           PreparedStatement stmt =
connection.prepareStatement("create table orders ( id integer not
null, client character varying(15) default ? not null)");
           stmt.setObject(1, "without-name");

       } catch (Exception e) {


org.postgresql.util.PSQLException: ERROR: there is no parameter $1
       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
       at org.postgresql.core.v3.QueryExecutorImpl.processResults
       at org.postgresql.core.v3.QueryExecutorImpl.execute(
       at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(
       at test.DB.main(
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(
       at sun.reflect.DelegatingMethodAccessorImpl.invoke
       at java.lang.reflect.Method.invoke(
       at com.intellij.rt.execution.application.AppMain.main(

JDBC: 8.1.404
Database: 8.1.4

Enrique Rodriguez Lasterra
lasterra AT javahispano DOT org
Asociación sin ánimo de lucro sobre java
Spanish non profit association about java


pgsql-jdbc by date

Next:From: Mark LewisDate: 2006-09-13 17:20:51
Subject: Re: create tables and prepared statements with params
Previous:From: Enrique Rodríguez LasterraDate: 2006-09-13 17:02:25
Subject: PreparedStatement and CreateTable

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group