formating and spelling fixes to my last doc update
This commit is contained in:
parent
d7decc61d9
commit
4ac5534456
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/jdbc.sgml,v 1.31 2001/11/26 19:07:11 momjian Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/jdbc.sgml,v 1.32 2001/11/27 01:20:17 barry Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="jdbc">
|
<chapter id="jdbc">
|
||||||
@ -379,9 +379,8 @@ db.close();
|
|||||||
Any time you want to issue <acronym>SQL</acronym> statements to
|
Any time you want to issue <acronym>SQL</acronym> statements to
|
||||||
the database, you require a <classname>Statement</classname> or
|
the database, you require a <classname>Statement</classname> or
|
||||||
<classname>PreparedStatement</classname> instance. Once you have
|
<classname>PreparedStatement</classname> instance. Once you have
|
||||||
a <classname>Statement</classname> or <classname>PreparedStatement
|
a <classname>Statement</classname> or
|
||||||
</classname>, you
|
<classname>PreparedStatement</classname>, you can use issue a
|
||||||
can use issue a
|
|
||||||
query. This will return a <classname>ResultSet</classname>
|
query. This will return a <classname>ResultSet</classname>
|
||||||
instance, which contains the entire result. <xref
|
instance, which contains the entire result. <xref
|
||||||
linkend="jdbc-query-example"> illustrates this process.
|
linkend="jdbc-query-example"> illustrates this process.
|
||||||
@ -406,7 +405,7 @@ st.close();
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
This example will issues the same query as before using
|
This example will issue the same query as before using
|
||||||
a <classname>PreparedStatement</classname>
|
a <classname>PreparedStatement</classname>
|
||||||
and a bind value in the query.
|
and a bind value in the query.
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@ -430,7 +429,8 @@ st.close();
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The following must be considered when using the
|
The following must be considered when using the
|
||||||
<classname>Statement</classname> interface:
|
<classname>Statement</classname> or
|
||||||
|
<classname>PreparedStatement</classname> interface:
|
||||||
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -440,7 +440,8 @@ st.close();
|
|||||||
open the connection and use it for the connection's
|
open the connection and use it for the connection's
|
||||||
lifetime. But you have to remember that only one
|
lifetime. But you have to remember that only one
|
||||||
<classname>ResultSet</classname> can exist per
|
<classname>ResultSet</classname> can exist per
|
||||||
<classname>Statement</classname> at a given time.
|
<classname>Statement</classname> or
|
||||||
|
<classname>PreparedStatement</classname> at a given time.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
@ -464,7 +465,8 @@ st.close();
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
When you are done using the <classname>Statement</classname>
|
When you are done using the <classname>Statement</classname>
|
||||||
you should close the <classname>Statement</classname>.
|
or <classname>PreparedStatement</classname>
|
||||||
|
you should close it.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@ -532,6 +534,8 @@ st.close();
|
|||||||
update, or delete statement.
|
update, or delete statement.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<example id="jdbc-delete-example">
|
||||||
|
<title>Simple Delete Example</title>
|
||||||
<para>
|
<para>
|
||||||
This example will issue a simple delete and print out the number
|
This example will issue a simple delete and print out the number
|
||||||
of rows deleted.
|
of rows deleted.
|
||||||
@ -544,6 +548,7 @@ System.out.println(rowsDeleted + " rows deleted");
|
|||||||
st.close();
|
st.close();
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="jdbc-ddl">
|
<sect1 id="jdbc-ddl">
|
||||||
@ -557,6 +562,8 @@ st.close();
|
|||||||
however it doesn't return a result.
|
however it doesn't return a result.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<example id="jdbc-drop-table-example">
|
||||||
|
<title>Drop Table Example</title>
|
||||||
<para>
|
<para>
|
||||||
This example will drop a table.
|
This example will drop a table.
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@ -565,18 +572,20 @@ ResultSet rs = st.executeQuery("DROP TABLE mytable");
|
|||||||
st.close();
|
st.close();
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
</example>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="jdbc-binary-data">
|
<sect1 id="jdbc-binary-data">
|
||||||
<title>Storing Binary Data</title>
|
<title>Storing Binary Data</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<application>PostgreSQL</application> provides two distinct way to
|
<application>PostgreSQL</application> provides two distinct ways to
|
||||||
store binary data. Binary data can be stored in a table using
|
store binary data. Binary data can be stored in a table using
|
||||||
<application>PostgreSQL's</application> binary datatype
|
<application>PostgreSQL's</application> binary datatype
|
||||||
<type>bytea</type>, or by using the <firstterm>Large Object</firstterm>
|
<type>bytea</type>, or by using the <firstterm>Large Object</firstterm>
|
||||||
feature which stores the binary data in a separate table in a special
|
feature which stores the binary data in a separate table in a special
|
||||||
format, and refers to from your own tables by an <type>OID</type> value.
|
format, and refers to that table by storing a value of type
|
||||||
|
<type>OID</type> in your table.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -598,8 +607,8 @@ st.close();
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
7.2 is the first release that the <acronym>JDBC</acronym> Driver
|
7.2 is the first release of the <acronym>JDBC</acronym> Driver
|
||||||
supports the <type>bytea</type> datatype. The introduction of
|
that supports the <type>bytea</type> datatype. The introduction of
|
||||||
this functionality in 7.2 has introduced a change in behavior
|
this functionality in 7.2 has introduced a change in behavior
|
||||||
as compared to previous releases. In 7.2 the methods
|
as compared to previous releases. In 7.2 the methods
|
||||||
<function>getBytes()</function>, <function>setBytes()</function>,
|
<function>getBytes()</function>, <function>setBytes()</function>,
|
||||||
@ -702,7 +711,7 @@ ps.close();
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Here you can see how the Large Object is retrieved as an
|
Here the binary data was retrieved as an
|
||||||
<classname>byte[]</classname>. You could have used a
|
<classname>byte[]</classname>. You could have used a
|
||||||
<classname>InputStream</classname> object instead.
|
<classname>InputStream</classname> object instead.
|
||||||
</para>
|
</para>
|
||||||
@ -721,6 +730,8 @@ CREATE TABLE imagesLO (imgname text, imgOID OID);
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
// All LargeObject API calls must be within a transaction
|
// All LargeObject API calls must be within a transaction
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
|
|
||||||
|
// Get the Large Object Manager to perform operations with
|
||||||
LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
|
LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
|
||||||
|
|
||||||
//create a new large object
|
//create a new large object
|
||||||
@ -760,6 +771,8 @@ fis.close();
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
// All LargeObject API calls must be within a transaction
|
// All LargeObject API calls must be within a transaction
|
||||||
conn.setAutoCommit(false);
|
conn.setAutoCommit(false);
|
||||||
|
|
||||||
|
// Get the Large Object Manager to perform operations with
|
||||||
LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
|
LargeObjectManager lobj = ((org.postgresql.Connection)conn).getLargeObjectAPI();
|
||||||
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT imgOID FROM imagesLO WHERE imgname=?");
|
PreparedStatement ps = con.prepareStatement("SELECT imgOID FROM imagesLO WHERE imgname=?");
|
||||||
@ -775,7 +788,7 @@ if (rs != null) {
|
|||||||
byte buf[] = new byte[obj.size()];
|
byte buf[] = new byte[obj.size()];
|
||||||
obj.read(buf, 0, obj.size());
|
obj.read(buf, 0, obj.size());
|
||||||
//do something with the data read here
|
//do something with the data read here
|
||||||
}
|
|
||||||
// Close the object
|
// Close the object
|
||||||
obj.close();
|
obj.close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user