Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39116bf

Browse files
author
Peter Mount
committed
Another attempt
1 parent1b266fb commit39116bf

File tree

9 files changed

+112
-34
lines changed

9 files changed

+112
-34
lines changed

‎src/interfaces/jdbc/CHANGELOG

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
Web Apr 12 22:14:00 BST 2000 peter@retep.org.uk
2+
- Implemented the JDBC2 Blob interface, and ResultSet.getBlob().
3+
4+
Wed Apr 12 20:20:00 BST 2000 peter@retep.org.uk
5+
- Fixed bug in ResultSet.absolute(). Negative rows are now supported.
6+
- Implemented ResultSet.relative(), afterLast().
7+
8+
Tue Feb 1 21:40:00 GMT 2000 peter@retep.org.uk
9+
- Finally imported the contributed javax extensions by Assaf Arkin
10+
arkin@exoffice.com
11+
12+
Mon Jan 24 21:00:00 GMT 2000 peter@retep.org.uk
13+
- Finally introduced the 7.0 additions to the core CVS repository.
14+
- All source files are now under the org.postgresql package (previously
15+
they were under postgresql). The package lines now changed
16+
accordingly.
17+
- The Makefile was rewritten so it should now work on machines that
18+
can't handle the $( ) syntax.
19+
- Dutch translation by Arnout Kuiper (ajkuiper@wxs.nl)
20+
121
Mon Sep 13 23:56:00 BST 1999 peter@retep.org.uk
222
- PG_Stream.SendChar() optimised, increased default buffer size of
323
output stream to 8k, and introduced an 8k buffer on the input stream

‎src/interfaces/jdbc/example/ImageViewer.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
importjava.awt.event.*;
55
importjava.io.*;
66
importjava.sql.*;
7-
importpostgresql.largeobject.*;
7+
importorg.postgresql.largeobject.*;
88

99
/**
1010
* This example is a small application that stores and displays images
@@ -14,11 +14,11 @@
1414
* on the first time you run it, select "Initialise" in the "PostgreSQL"
1515
* menu.
1616
*
17-
* Important note: You will notice we import the postgresql.largeobject
18-
* package, but don't import the postgresql package. The reason for this is
17+
* Important note: You will notice we import theorg.postgresql.largeobject
18+
* package, but don't import theorg.postgresql package. The reason for this is
1919
* that importing postgresql can confuse javac (we have conflicting class names
20-
* in postgresql.* and java.sql.*). This doesn't cause any problems, as long
21-
* as no code imports postgresql.
20+
* inorg.postgresql.* and java.sql.*). This doesn't cause any problems, as
21+
*longas no code importsorg.postgresql.
2222
*
2323
* Under normal circumstances, code using any jdbc driver only needs to import
2424
* java.sql, so this isn't a problem.
@@ -183,7 +183,7 @@ public void actionPerformed(ActionEvent e) {
183183
f.add("Center",canvas =newimageCanvas());
184184

185185
// Load the driver
186-
Class.forName("postgresql.Driver");
186+
Class.forName("org.postgresql.Driver");
187187

188188
// Connect to database
189189
System.out.println("Connecting to Database URL = " +url);
@@ -196,7 +196,7 @@ public void actionPerformed(ActionEvent e) {
196196
db.setAutoCommit(false);
197197

198198
// Also, get the LargeObjectManager for this connection
199-
lom = ((postgresql.Connection)db).getLargeObjectAPI();
199+
lom = ((org.postgresql.Connection)db).getLargeObjectAPI();
200200

201201
// Now refresh the image selection list
202202
refreshList();
@@ -273,7 +273,7 @@ public void run() {
273273

274274
try {
275275
// fetch the large object manager
276-
LargeObjectManagerlom = ((postgresql.Connection)db).getLargeObjectAPI();
276+
LargeObjectManagerlom = ((org.postgresql.Connection)db).getLargeObjectAPI();
277277

278278
System.out.println("Importing file");
279279
// A temporary buffer - this can be as large as you like
@@ -425,7 +425,7 @@ public static void instructions()
425425
{
426426
System.err.println("java example.ImageViewer jdbc-url user password");
427427
System.err.println("\nExamples:\n");
428-
System.err.println("java -Djdbc.driver=postgresql.Driver example.ImageViewer jdbc:postgresql:test postgres password\n");
428+
System.err.println("java -Djdbc.driver=org.postgresql.Driver example.ImageViewer jdbc:postgresql:test postgres password\n");
429429

430430
System.err.println("This example tests the binary large object api of the driver.\nBasically, it will allow you to store and view images held in the database.");
431431
System.err.println("Note: If you are running this for the first time on a particular database,\nyou have to select\"Initialise\" in the\"PostgreSQL\" menu.\nThis will create a table used to store image names.");
@@ -442,7 +442,7 @@ public static void main(String args[])
442442
}
443443

444444
try {
445-
Frameframe =newFrame("PostgreSQL ImageViewerv6.4 rev 1");
445+
Frameframe =newFrame("PostgreSQL ImageViewerv7.0 rev 1");
446446
frame.setLayout(newBorderLayout());
447447
ImageViewerviewer =newImageViewer(frame,args[0],args[1],args[2]);
448448
frame.pack();

‎src/interfaces/jdbc/example/basic.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
importjava.text.*;
66

77
/**
8+
*
9+
* $Id: basic.java,v 1.4 2000/04/26 05:32:00 peter Exp $
10+
*
811
* This example tests the basic components of the JDBC driver, and shows
912
* how even the simplest of queries can be implemented.
1013
*
1114
* To use this example, you need a database to be in existence. This example
1215
* will create a table called basic.
1316
*
17+
* Note: This will only work with post 7.0 drivers.
18+
*
1419
*/
1520

1621
publicclassbasic
@@ -25,7 +30,7 @@ public basic(String args[]) throws ClassNotFoundException, FileNotFoundException
2530
Stringpwd =args[2];
2631

2732
// Load the driver
28-
Class.forName("postgresql.Driver");
33+
Class.forName("org.postgresql.Driver");
2934

3035
// Connect to database
3136
System.out.println("Connecting to Database URL = " +url);

‎src/interfaces/jdbc/example/blobtest.java

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
importjava.io.*;
44
importjava.sql.*;
5-
importpostgresql.largeobject.*;
5+
importorg.postgresql.largeobject.*;
66

77
/**
88
* This test attempts to create a blob in the database, then to read
99
* it back.
1010
*
11-
* Important note: You will notice we import the postgresql.largeobject
12-
* package, but don't import the postgresql package. The reason for this is
11+
* Important note: You will notice we import theorg.postgresql.largeobject
12+
* package, but don't import theorg.postgresql package. The reason for this is
1313
* that importing postgresql can confuse javac (we have conflicting class names
14-
* in postgresql.* and java.sql.*). This doesn't cause any problems, as long
15-
* as no code imports postgresql.
14+
* inorg.postgresql.* and java.sql.*). This doesn't cause any problems, as
15+
*longas no code importsorg.postgresql.
1616
*
1717
* Under normal circumstances, code using any jdbc driver only needs to import
1818
* java.sql, so this isn't a problem.
@@ -35,12 +35,17 @@ public blobtest(String args[]) throws ClassNotFoundException, FileNotFoundExcept
3535
Stringpwd =args[2];
3636

3737
// Load the driver
38-
Class.forName("postgresql.Driver");
38+
Class.forName("org.postgresql.Driver");
3939

4040
// Connect to database
4141
System.out.println("Connecting to Database URL = " +url);
4242
db =DriverManager.getConnection(url,usr,pwd);
43-
System.out.println("Connected...Now creating a statement");
43+
44+
// This is required for all LargeObject calls
45+
System.out.println("Connected... First turn off autoCommit()");
46+
db.setAutoCommit(false);
47+
48+
System.out.println("Now creating a statement");
4449
s =db.createStatement();
4550

4651
// Now run tests using postgresql's own Large object api
@@ -66,16 +71,22 @@ public blobtest(String args[]) throws ClassNotFoundException, FileNotFoundExcept
6671
*/
6772
publicvoidownapi()throwsFileNotFoundException,IOException,SQLException
6873
{
69-
System.out.println("\n----------------------------------------------------------------------\nTesting postgresql large object api\n");
74+
System.out.println("\n----------------------------------------------------------------------\nTesting postgresql large object api\n----------------------------------------------------------------------\n");
7075

7176
// Internally, the driver provides JDBC compliant methods to access large
72-
// objects, however the unique methods available to postgresql makes things
77+
// objects, however the unique methods available to postgresql makes
78+
// things a little easier.
7379
System.out.println("Gaining access to large object api");
74-
lobj = ((postgresql.Connection)db).getLargeObjectAPI();
80+
lobj = ((org.postgresql.Connection)db).getLargeObjectAPI();
7581

7682
intoid =ownapi_test1();
7783
ownapi_test2(oid);
78-
//ownapi_test3(oid);
84+
85+
// Now call the jdbc2api test
86+
jdbc2api(oid);
87+
88+
// finally delete the large object
89+
ownapi_test3(oid);
7990
System.out.println("\n\nOID="+oid);
8091
}
8192

@@ -157,21 +168,63 @@ private void ownapi_test3(int oid) throws SQLException
157168
lobj.unlink(oid);
158169
}
159170

160-
//=========================================================================
171+
//=======================================================================
172+
// This tests the Blob interface of the JDBC 2.0 specification
173+
publicvoidjdbc2api(intoid)throwsSQLException,IOException
174+
{
175+
System.out.println("Testing JDBC2 Blob interface:");
176+
jdbc2api_cleanup();
177+
178+
System.out.println("Creating Blob on large object "+oid);
179+
s.executeUpdate("create table basic (a oid)");
180+
181+
System.out.println("Inserting row");
182+
s.executeUpdate("insert into basic values ("+oid+")");
183+
184+
System.out.println("Selecting row");
185+
ResultSetrs =s.executeQuery("select a from basic");
186+
if(rs!=null) {
187+
while(rs.next()) {
188+
System.out.println("Fetching Blob");
189+
Blobb =rs.getBlob("a");
190+
System.out.println("Blob.length() = "+b.length());
191+
System.out.println("Characters 400-500:");
192+
System.out.write(b.getBytes(400l,100));
193+
System.out.println();
194+
}
195+
rs.close();
196+
}
197+
198+
System.out.println("Cleaning up");
199+
jdbc2api_cleanup();
200+
}
201+
202+
privatevoidjdbc2api_cleanup()throwsSQLException
203+
{
204+
db.setAutoCommit(true);
205+
try {
206+
s.executeUpdate("drop table basic");
207+
}catch(Exceptionex) {
208+
// We ignore any errors here
209+
}
210+
db.setAutoCommit(false);
211+
}
212+
213+
//=======================================================================
161214

162215
publicstaticvoidinstructions()
163216
{
164217
System.err.println("java example.blobtest jdbc-url user password [debug]");
165218
System.err.println("\nExamples:\n");
166-
System.err.println("java -Djdbc.driver=postgresql.Driver example.blobtest jdbc:postgresql:test postgres password\nThis will run the tests on the database test on the local host.\n");
167-
System.err.println("java -Djdbc.driver=postgresql.Driver example.blobtest jdbc:postgresql:test postgres password debug\nThis is the same as above, but will output debug information.\n");
219+
System.err.println("java -Djdbc.driver=org.postgresql.Driver example.blobtest jdbc:postgresql:test postgres password\nThis will run the tests on the database test on the local host.\n");
220+
System.err.println("java -Djdbc.driver=org.postgresql.Driver example.blobtest jdbc:postgresql:test postgres password debug\nThis is the same as above, but will output debug information.\n");
168221

169222
System.err.println("This example tests the binary large object api of the driver.\nThis allows images or java objects to be stored in the database, and retrieved\nusing both postgresql's own api, and the standard JDBC api.");
170223
}
171224

172225
publicstaticvoidmain(Stringargs[])
173226
{
174-
System.out.println("PostgreSQL blobtestv6.3 rev 1\n");
227+
System.out.println("PostgreSQL blobtestv7.0 rev 1\n");
175228

176229
if(args.length<3) {
177230
instructions();

‎src/interfaces/jdbc/example/corba/StockDB.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* that an object could be changed by another client, and we need to ensure that
1414
* the returned data is live and accurate.
1515
*
16-
* $Id: StockDB.java,v 1.1 1999/01/25 21:22:03 scrappy Exp $
16+
* $Id: StockDB.java,v 1.2 2000/04/26 05:32:01 peter Exp $
1717
*/
1818
publicclassStockDB
1919
{
@@ -24,7 +24,7 @@ public class StockDB
2424
intid = -1;
2525

2626
publicvoidconnect(Stringurl,Stringusr,Stringpwd)throwsException {
27-
Class.forName("postgresql.Driver");
27+
Class.forName("org.postgresql.Driver");
2828
System.out.println("Connecting to "+url);
2929
con =DriverManager.getConnection(url,usr,pwd);
3030
st =con.createStatement();

‎src/interfaces/jdbc/example/datestyle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public datestyle(String args[]) throws ClassNotFoundException, FileNotFoundExcep
3838
Stringpwd =args[2];
3939

4040
// Load the driver
41-
Class.forName("postgresql.Driver");
41+
Class.forName("org.postgresql.Driver");
4242

4343
// Connect to database
4444
System.out.println("Connecting to Database URL = " +url);

‎src/interfaces/jdbc/example/metadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public metadata(String args[]) throws ClassNotFoundException, FileNotFoundExcept
113113
Stringpwd =args[2];
114114

115115
// Load the driver
116-
Class.forName("postgresql.Driver");
116+
Class.forName("org.postgresql.Driver");
117117

118118
// Connect to database
119119
System.out.println("Connecting to Database URL = " +url);

‎src/interfaces/jdbc/example/psql.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public psql(String args[]) throws ClassNotFoundException, FileNotFoundException,
2323
Stringpwd =args[2];
2424

2525
// Load the driver
26-
Class.forName("postgresql.Driver");
26+
Class.forName("org.postgresql.Driver");
2727

2828
// Connect to database
2929
System.out.println("Connecting to Database URL = " +url);

‎src/interfaces/jdbc/example/threadsafe.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
importjava.text.*;
66

77
// rare in user code, but we use the LargeObject API in this test
8-
importpostgresql.largeobject.*;
8+
importorg.postgresql.largeobject.*;
99

1010
/**
1111
* This example tests the thread safety of the driver.
@@ -28,7 +28,7 @@ public threadsafe(String args[]) throws ClassNotFoundException, FileNotFoundExce
2828
Stringpwd =args[2];
2929

3030
// Load the driver
31-
Class.forName("postgresql.Driver");
31+
Class.forName("org.postgresql.Driver");
3232

3333
// Connect to database
3434
System.out.println("Connecting to Database URL = " +url);
@@ -263,7 +263,7 @@ public thread3(Connection c) throws SQLException {
263263
//st = c.createStatement();
264264

265265
// create a blob
266-
lom = ((postgresql.Connection)c).getLargeObjectAPI();
266+
lom = ((org.postgresql.Connection)c).getLargeObjectAPI();
267267
oid =lom.create();
268268
System.out.println("Thread 3 has created a blob of oid "+oid);
269269
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp