Multiple SQL statements in a java program for postgresql DB - Mailing list pgsql-novice

From suhail sarwar
Subject Multiple SQL statements in a java program for postgresql DB
Date
Msg-id PM.12704.988556404@pmweb8.uk1.bibliotech.net
Whole thread Raw
List 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
statementin 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
matterwhether 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

pgsql-novice by date:

Previous
From: "suhail sarwar"
Date:
Subject: Variables in SQL statements
Next
From: "Bob Whitehouse"
Date:
Subject: Function help