Multiple SQL statements in a java program for postgresql DB

Поиск
Список
Период
Сортировка
От suhail sarwar
Тема Multiple SQL statements in a java program for postgresql DB
Дата
Msg-id PM.12704.988556404@pmweb8.uk1.bibliotech.net
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "suhail sarwar"
Дата:
Сообщение: Variables in SQL statements
Следующее
От: "Bob Whitehouse"
Дата:
Сообщение: Function help