From 4ac5534456aa869d029a646fdc389df673fdec03 Mon Sep 17 00:00:00 2001 From: Barry Lind Date: Tue, 27 Nov 2001 01:20:17 +0000 Subject: [PATCH] formating and spelling fixes to my last doc update --- doc/src/sgml/jdbc.sgml | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/doc/src/sgml/jdbc.sgml b/doc/src/sgml/jdbc.sgml index fc3106ad3e..2aaf36cb0d 100644 --- a/doc/src/sgml/jdbc.sgml +++ b/doc/src/sgml/jdbc.sgml @@ -1,5 +1,5 @@ @@ -379,9 +379,8 @@ db.close(); Any time you want to issue SQL statements to the database, you require a Statement or PreparedStatement instance. Once you have - a Statement or PreparedStatement - , you - can use issue a + a Statement or + PreparedStatement, you can use issue a query. This will return a ResultSet instance, which contains the entire result. illustrates this process. @@ -406,7 +405,7 @@ st.close(); - This example will issues the same query as before using + This example will issue the same query as before using a PreparedStatement and a bind value in the query. @@ -430,7 +429,8 @@ st.close(); The following must be considered when using the - Statement interface: + Statement or + PreparedStatement interface: @@ -440,7 +440,8 @@ st.close(); open the connection and use it for the connection's lifetime. But you have to remember that only one ResultSet can exist per - Statement at a given time. + Statement or + PreparedStatement at a given time. @@ -464,7 +465,8 @@ st.close(); When you are done using the Statement - you should close the Statement. + or PreparedStatement + you should close it. @@ -532,6 +534,8 @@ st.close(); update, or delete statement. + + Simple Delete Example This example will issue a simple delete and print out the number of rows deleted. @@ -544,6 +548,7 @@ System.out.println(rowsDeleted + " rows deleted"); st.close(); + @@ -557,6 +562,8 @@ st.close(); however it doesn't return a result. + + Drop Table Example This example will drop a table. @@ -565,18 +572,20 @@ ResultSet rs = st.executeQuery("DROP TABLE mytable"); st.close(); + Storing Binary Data - PostgreSQL provides two distinct way to + PostgreSQL provides two distinct ways to store binary data. Binary data can be stored in a table using PostgreSQL's binary datatype bytea, or by using the Large Object feature which stores the binary data in a separate table in a special - format, and refers to from your own tables by an OID value. + format, and refers to that table by storing a value of type + OID in your table. @@ -598,8 +607,8 @@ st.close(); - 7.2 is the first release that the JDBC Driver - supports the bytea datatype. The introduction of + 7.2 is the first release of the JDBC Driver + that supports the bytea datatype. The introduction of this functionality in 7.2 has introduced a change in behavior as compared to previous releases. In 7.2 the methods getBytes(), setBytes(), @@ -702,7 +711,7 @@ ps.close(); - Here you can see how the Large Object is retrieved as an + Here the binary data was retrieved as an byte[]. You could have used a InputStream object instead. @@ -721,6 +730,8 @@ CREATE TABLE imagesLO (imgname text, imgOID OID); // All LargeObject API calls must be within a transaction conn.setAutoCommit(false); + +// Get the Large Object Manager to perform operations with LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI(); //create a new large object @@ -760,6 +771,8 @@ fis.close(); // All LargeObject API calls must be within a transaction conn.setAutoCommit(false); + +// Get the Large Object Manager to perform operations with LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI(); PreparedStatement ps = con.prepareStatement("SELECT imgOID FROM imagesLO WHERE imgname=?"); @@ -775,7 +788,7 @@ if (rs != null) { byte buf[] = new byte[obj.size()]; obj.read(buf, 0, obj.size()); //do something with the data read here - } + // Close the object obj.close(); }