From: Enrique Rodríguez Lasterra <lasterra@javahispano.org>
To: pgsql-jdbc@postgresql.org
Subject: PreparedStatement and CreateTable
Date: Wed, 13 Sep 2006 19:02:25 +0200
Message-ID: <6daed2a30609131002x70758ecftb75810809729212e@mail.gmail.com> (raw)
I 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.
Here is all the info.
Code
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 {
Class.forName("org.postgresql.Driver");
connection =
DriverManager.getConnection("jdbc[tongue]ostgresql://192.168.4.221/canyamo-test",
"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");
stmt.executeUpdate();//stmt.execute();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Exception
org.postgresql.util.PSQLException: ERROR: there is no parameter $1
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
QueryExecutorImpl.java:1527)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
QueryExecutorImpl.java:1311)
at org.postgresql.core.v3.QueryExecutorImpl.execute(
QueryExecutorImpl.java:190)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
AbstractJdbc2Statement.java:354)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(
AbstractJdbc2Statement.java:308)
at test.DB.main(DB.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java
:90)
Versions
JDBC: 8.1.404
Database: 8.1.4
--
_______________________________
Enrique Rodriguez Lasterra
lasterra AT javahispano DOT org
http://www.javahispano.org
Asociación sin ánimo de lucro sobre java
Spanish non profit association about java
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: lasterra@javahispano.org
Subject: Re: PreparedStatement and CreateTable
In-Reply-To: <6daed2a30609131002x70758ecftb75810809729212e@mail.gmail.com>
References: <6daed2a30609131002x70758ecftb75810809729212e@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox