Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9142ca2f
Commit
9142ca2f
authored
Mar 05, 2001
by
Peter Mount
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes...
parent
e2e84a1c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
40 deletions
+140
-40
src/interfaces/jdbc/org/postgresql/Driver.java.in
src/interfaces/jdbc/org/postgresql/Driver.java.in
+4
-0
src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java
src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java
+95
-0
src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java
...terfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java
+41
-40
No files found.
src/interfaces/jdbc/org/postgresql/Driver.java.in
View file @
9142ca2f
...
@@ -35,6 +35,10 @@ public class Driver implements java.sql.Driver
...
@@ -35,6 +35,10 @@ public class Driver implements java.sql.Driver
//
my
early
jdbc
work
did
-
and
that
was
based
on
other
examples
).
//
my
early
jdbc
work
did
-
and
that
was
based
on
other
examples
).
//
Placing
it
here
,
means
that
the
driver
is
registered
once
only
.
//
Placing
it
here
,
means
that
the
driver
is
registered
once
only
.
java
.
sql
.
DriverManager
.
registerDriver
(
new
Driver
());
java
.
sql
.
DriverManager
.
registerDriver
(
new
Driver
());
//
New
in
7.1
-
register
ourselves
with
the
JVM
-
JDK1
.3
+
only
@
JDK1
.3
ONLY
@
org
.
postgresql
.
core
.
ConnectionHook
.
init
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
src/interfaces/jdbc/org/postgresql/core/ConnectionHook.java
0 → 100644
View file @
9142ca2f
package
org.postgresql.core
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
org.postgresql.Connection
;
/**
* ConnectionHook keeps track of all open Connections. It's used only in
* Java2 (JDK1.3+) VM's, and it's purpose is to close all connections cleanly
* when the VM terminates.
*
* Important: This only works for JDK1.3 or later as it uses methods new to
* that JDK.
*
* This is a singleton object ;-)
*
* How it works: This is an initiated but un-started Thread. When it's created,
* it registers it'self with the Runtime.addShutdownHook() method.
*
* When a Connection is made, two static methods in org.postgresql.Driver are
* called. For pre JDK1.3 these are noops, but for 1.3+ ANT adds calls to
* methods in this class, which add/remove it from an ArrayList.
*
* Now when the VM terminates it starts this thread, which then Itterates
* through the ArrayList and closes each Connection.
*
* Obviously this doesn't trap things like Runtime.halt() or SIGKILL etc, but
* this captures 99% of all other forms of VM termination.
*
*/
public
class
ConnectionHook
implements
Runnable
{
/**
* This ensures that the hook is created and the system is notified of it.
*
* Important: We have to use an instance, as we have to pass a reference to
* the VM.
*/
private
static
final
ConnectionHook
SINGLETON
=
new
ConnectionHook
();
/**
* The currently open connections
*/
private
ArrayList
cons
=
new
ArrayList
();
/**
* Constructor. This is private because we are a singleton. Here we set
* our selves up, and then register with the VM.
*/
private
ConnectionHook
()
{
super
();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
this
));
}
/**
* Called by Driver, this simply forces us to be created.
*/
public
static
final
void
init
()
{
}
/**
* This is used by org.postgresql.Connection to register itself. Because it's
* called internally, we don't bother with checking to see if it's already
* present (performance boost).
*/
public
static
final
void
open
(
Connection
con
)
{
SINGLETON
.
cons
.
add
(
con
);
}
/**
* This is used by org.postgresql.Connection to remove itself.
*/
public
static
final
void
close
(
Connection
con
)
{
SINGLETON
.
cons
.
remove
(
con
);
}
/**
* This is called by the VM when it terminates. It itterates through the list
* of connections and implicitly closes them.
*/
public
void
run
()
{
Iterator
i
=
cons
.
iterator
();
while
(
i
.
hasNext
())
{
Connection
c
=
(
Connection
)
i
.
next
();
try
{
c
.
close
();
}
catch
(
SQLException
e
)
{
// Ignore as at this point we are dying anyhow ;-)
}
}
}
}
src/interfaces/jdbc/org/postgresql/jdbc2/CallableStatement.java
View file @
9142ca2f
...
@@ -214,6 +214,7 @@ public int getInt(int parameterIndex) throws SQLException {
...
@@ -214,6 +214,7 @@ public int getInt(int parameterIndex) throws SQLException {
* desired number of digits to the right of the decimal point
* desired number of digits to the right of the decimal point
* @return the parameter value; if the value is SQL NULL, the result is null
* @return the parameter value; if the value is SQL NULL, the result is null
* @exception SQLException if a database-access error occurs.
* @exception SQLException if a database-access error occurs.
* @deprecated in Java2.0
*/
*/
public
BigDecimal
getBigDecimal
(
int
parameterIndex
,
int
scale
)
public
BigDecimal
getBigDecimal
(
int
parameterIndex
,
int
scale
)
throws
SQLException
{
throws
SQLException
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment