Multiple SQL statements in a java program for postgresql DB

From: "suhail sarwar" <sarwar(at)postmaster(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Multiple SQL statements in a java program for postgresql DB
Date: 2001-04-29 15:00:04
Message-ID: PM.12704.988556404@pmweb8.uk1.bibliotech.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I have a java program that interfaces with a postgresql database and need to know how to insert more than 1 sql statement in the program. The second sql statement always gets ignored for some reason. I have inclded some of the code below:

db = DriverManager.getConnection(url, "icm00sg", "");

PreparedStatement st = db.prepareStatement("CREATE TABLE Test1 " +
"(CUS_NO INTEGER, NAME VARCHAR(30), AGE INTEGER, " +
"STREETNAME VARCHAR(30), STREETNO INTEGER)");

ResultSet rs = st.executeQuery();

PreparedStatement stt = db.prepareStatement("INSERT INTO Test1 " +
"VALUES (100, 'yahoo', 23, 'donald', 236)");

stt.executeUpdate();

The first statement to create the table always works but the second statement to insert values does not. It does not matter whether the second statement creates another table or prints one out, it just won't work.

Does anyone have any ideas.

Any help much appreciated.

Sarwar

Browse pgsql-novice by date

  From Date Subject
Next Message suhail sarwar 2001-04-29 16:55:24 Variables in SQL statements
Previous Message Albert REINER 2001-04-28 20:33:53 Re: Attribute 'name' not found ERROR for postgres and java