~ubuntu-branches/ubuntu/oneiric/libpgjava/oneiric

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/example/basic.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2005-04-21 14:25:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050421142511-wibh5vc31fkrorx7
Tags: 7.4.7-3
Built with sources...

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import java.io.*;
4
4
import java.sql.*;
5
 
import java.text.*;
6
5
 
7
6
/*
8
7
 *
9
 
 * $Id: basic.java,v 1.11 2001/11/25 23:26:56 barry Exp $
 
8
 * $Id: basic.java,v 1.14 2003/09/09 11:24:04 barry Exp $
10
9
 *
11
10
 * This example tests the basic components of the JDBC driver, and shows
12
11
 * how even the simplest of queries can be implemented.
87
86
                st.executeUpdate("insert into basic values (3,1)");
88
87
 
89
88
                // This shows how to get the oid of a just inserted row
90
 
                // updated for 7.1
91
89
                st.executeUpdate("insert into basic values (4,1)");
92
 
                long insertedOID = ((org.postgresql.Statement)st).getLastOID();
 
90
                long insertedOID = ((org.postgresql.PGStatement)st).getLastOID();
93
91
                System.out.println("Inserted row with oid " + insertedOID);
94
92
 
95
93
                // Now change the value of b from 1 to 8
138
136
                // result if you don't know what column number a value is in
139
137
 
140
138
 
 
139
 
141
140
                System.out.println("performing another query");
142
141
                rs = st.executeQuery("select * from basic where b>1");
143
142
                if (rs != null)
165
164
                // Now test maxrows by setting it to 3 rows
166
165
 
167
166
 
 
167
 
168
168
                st.setMaxRows(3);
169
169
                System.out.println("performing a query limited to " + st.getMaxRows());
170
170
                rs = st.executeQuery("select a, b from basic");