Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
4ac55344
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ac55344
编写于
11月 27, 2001
作者:
B
Barry Lind
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
formating and spelling fixes to my last doc update
上级
d7decc61
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
14 deletion
+27
-14
doc/src/sgml/jdbc.sgml
doc/src/sgml/jdbc.sgml
+27
-14
未找到文件。
doc/src/sgml/jdbc.sgml
浏览文件 @
4ac55344
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/jdbc.sgml,v 1.3
1 2001/11/26 19:07:11 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/jdbc.sgml,v 1.3
2 2001/11/27 01:20:17 barry
Exp $
-->
<chapter id="jdbc">
...
...
@@ -379,9 +379,8 @@ db.close();
Any time you want to issue <acronym>SQL</acronym> statements to
the database, you require a <classname>Statement</classname> or
<classname>PreparedStatement</classname> instance. Once you have
a <classname>Statement</classname> or <classname>PreparedStatement
</classname>, you
can use issue a
a <classname>Statement</classname> or
<classname>PreparedStatement</classname>, you can use issue a
query. This will return a <classname>ResultSet</classname>
instance, which contains the entire result. <xref
linkend="jdbc-query-example"> illustrates this process.
...
...
@@ -406,7 +405,7 @@ st.close();
</para>
<para>
This example will issue
s
the same query as before using
This example will issue the same query as before using
a <classname>PreparedStatement</classname>
and a bind value in the query.
<programlisting>
...
...
@@ -430,7 +429,8 @@ st.close();
<para>
The following must be considered when using the
<classname>Statement</classname> interface:
<classname>Statement</classname> or
<classname>PreparedStatement</classname> interface:
<itemizedlist>
<listitem>
...
...
@@ -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
<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>
</listitem>
...
...
@@ -464,7 +465,8 @@ st.close();
<listitem>
<para>
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>
</listitem>
</itemizedlist>
...
...
@@ -532,6 +534,8 @@ st.close();
update, or delete statement.
</para>
<example id="jdbc-delete-example">
<title>Simple Delete Example</title>
<para>
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();
</programlisting>
</para>
</example>
</sect1>
<sect1 id="jdbc-ddl">
...
...
@@ -557,6 +562,8 @@ st.close();
however it doesn't return a result.
</para>
<example id="jdbc-drop-table-example">
<title>Drop Table Example</title>
<para>
This example will drop a table.
<programlisting>
...
...
@@ -565,18 +572,20 @@ ResultSet rs = st.executeQuery("DROP TABLE mytable");
st.close();
</programlisting>
</para>
</example>
</sect1>
<sect1 id="jdbc-binary-data">
<title>Storing Binary Data</title>
<para>
<application>PostgreSQL</application> provides two distinct way to
<application>PostgreSQL</application> provides two distinct way
s
to
store binary data. Binary data can be stored in a table using
<application>PostgreSQL's</application> binary datatype
<type>bytea</type>, or by using the <firstterm>Large Object</firstterm>
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>
...
...
@@ -598,8 +607,8 @@ st.close();
</para>
<para>
7.2 is the first release
that
the <acronym>JDBC</acronym> Driver
supports the <type>bytea</type> datatype. The introduction of
7.2 is the first release
of
the <acronym>JDBC</acronym> Driver
that
supports the <type>bytea</type> 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
<function>getBytes()</function>, <function>setBytes()</function>,
...
...
@@ -702,7 +711,7 @@ ps.close();
</para>
<para>
Here
you can see how the Large Object i
s retrieved as an
Here
the binary data wa
s retrieved as an
<classname>byte[]</classname>. You could have used a
<classname>InputStream</classname> object instead.
</para>
...
...
@@ -721,6 +730,8 @@ CREATE TABLE imagesLO (imgname text, imgOID OID);
<programlisting>
// 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();
<programlisting>
// 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();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录