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
f37c1c48
Commit
f37c1c48
authored
Sep 06, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run pgjindent for Java folks.
parent
b4295d05
Changes
71
Show whitespace changes
Inline
Side-by-side
Showing
71 changed files
with
8890 additions
and
8017 deletions
+8890
-8017
src/interfaces/jdbc/example/Unicode.java
src/interfaces/jdbc/example/Unicode.java
+1
-1
src/interfaces/jdbc/example/basic.java
src/interfaces/jdbc/example/basic.java
+3
-1
src/interfaces/jdbc/example/corba/StockClient.java
src/interfaces/jdbc/example/corba/StockClient.java
+4
-4
src/interfaces/jdbc/example/corba/StockDispenserImpl.java
src/interfaces/jdbc/example/corba/StockDispenserImpl.java
+3
-3
src/interfaces/jdbc/example/corba/StockServer.java
src/interfaces/jdbc/example/corba/StockServer.java
+3
-3
src/interfaces/jdbc/example/psql.java
src/interfaces/jdbc/example/psql.java
+1
-1
src/interfaces/jdbc/org/postgresql/Driver.java.in
src/interfaces/jdbc/org/postgresql/Driver.java.in
+22
-18
src/interfaces/jdbc/org/postgresql/PGConnection.java
src/interfaces/jdbc/org/postgresql/PGConnection.java
+54
-54
src/interfaces/jdbc/org/postgresql/PGNotification.java
src/interfaces/jdbc/org/postgresql/PGNotification.java
+9
-9
src/interfaces/jdbc/org/postgresql/PGStatement.java
src/interfaces/jdbc/org/postgresql/PGStatement.java
+7
-7
src/interfaces/jdbc/org/postgresql/core/Encoding.java
src/interfaces/jdbc/org/postgresql/core/Encoding.java
+6
-6
src/interfaces/jdbc/org/postgresql/core/Notification.java
src/interfaces/jdbc/org/postgresql/core/Notification.java
+22
-19
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
+199
-198
src/interfaces/jdbc/org/postgresql/core/StartupPacket.java
src/interfaces/jdbc/org/postgresql/core/StartupPacket.java
+5
-4
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
+242
-238
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
...es/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
+1235
-1213
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
...c/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
+590
-511
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
...ces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
+90
-69
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
.../org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
+1
-1
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
...ces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
+376
-322
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Connection.java
...interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Connection.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSetMetaData.java
...ces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSetMetaData.java
+1
-1
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
+3
-3
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
...es/jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
+191
-179
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
...c/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
+9
-9
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
...ces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+1239
-1000
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
.../org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
+52
-52
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
...ces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+14
-13
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
+8
-8
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
...interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
+42
-42
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
+10
-8
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java
...ces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java
+1
-1
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc2/optional/BaseDataSource.java
...es/jdbc/org/postgresql/jdbc2/optional/BaseDataSource.java
+243
-211
src/interfaces/jdbc/org/postgresql/jdbc2/optional/ConnectionPool.java
...es/jdbc/org/postgresql/jdbc2/optional/ConnectionPool.java
+51
-45
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java
...s/jdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java
+85
-66
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
...c/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
+228
-171
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PoolingDataSource.java
...jdbc/org/postgresql/jdbc2/optional/PoolingDataSource.java
+421
-355
src/interfaces/jdbc/org/postgresql/jdbc2/optional/SimpleDataSource.java
.../jdbc/org/postgresql/jdbc2/optional/SimpleDataSource.java
+11
-9
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java
...terfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java
+76
-72
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java
...terfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java
+93
-88
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
...es/jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
+357
-345
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
...c/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
+326
-310
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
...ces/jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
+180
-168
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java
...ces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java
+1337
-1274
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
...ces/jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Connection.java
...interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Connection.java
+44
-44
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3DatabaseMetaData.java
...aces/jdbc/org/postgresql/jdbc3/Jdbc3DatabaseMetaData.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
...ces/jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
+2
-2
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
+14
-12
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSetMetaData.java
...ces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSetMetaData.java
+3
-3
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
+4
-4
src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java
...terfaces/jdbc/org/postgresql/largeobject/LargeObject.java
+6
-6
src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java
...s/jdbc/org/postgresql/largeobject/LargeObjectManager.java
+10
-9
src/interfaces/jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java
...aces/jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java
+27
-18
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
.../jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+77
-77
src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
...terfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
+2
-2
src/interfaces/jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
...rfaces/jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
+1
-1
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
+17
-16
src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
...erfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
+20
-20
src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
...erfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
+90
-84
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
.../jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+115
-114
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
...rg/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
+159
-131
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
...rg/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
+358
-293
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/OptionalTestSuite.java
...org/postgresql/test/jdbc2/optional/OptionalTestSuite.java
+14
-12
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
.../postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
+33
-26
src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
...rfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
+3
-3
src/interfaces/jdbc/org/postgresql/util/PGbytea.java
src/interfaces/jdbc/org/postgresql/util/PGbytea.java
+2
-2
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
+1
-0
src/interfaces/jdbc/org/postgresql/util/Serialize.java
src/interfaces/jdbc/org/postgresql/util/Serialize.java
+27
-16
No files found.
src/interfaces/jdbc/example/Unicode.java
View file @
f37c1c48
...
...
@@ -233,7 +233,7 @@ public class Unicode
catch
(
ClassNotFoundException
cnfe
)
{
log
(
"Unable to load driver"
,
cnfe
);
return
;
return
;
}
try
{
...
...
src/interfaces/jdbc/example/basic.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.text.*;
/*
*
* $Id: basic.java,v 1.1
2 2002/07/23 03:59:54 barry
Exp $
* $Id: basic.java,v 1.1
3 2002/09/06 21:23:05 momjian
Exp $
*
* This example tests the basic components of the JDBC driver, and shows
* how even the simplest of queries can be implemented.
...
...
@@ -137,6 +137,7 @@ public class basic
// result if you don't know what column number a value is in
System
.
out
.
println
(
"performing another query"
);
rs
=
st
.
executeQuery
(
"select * from basic where b>1"
);
if
(
rs
!=
null
)
...
...
@@ -164,6 +165,7 @@ public class basic
// Now test maxrows by setting it to 3 rows
st
.
setMaxRows
(
3
);
System
.
out
.
println
(
"performing a query limited to "
+
st
.
getMaxRows
());
rs
=
st
.
executeQuery
(
"select a, b from basic"
);
...
...
src/interfaces/jdbc/example/corba/StockClient.java
View file @
f37c1c48
...
...
@@ -9,7 +9,7 @@ import org.omg.CosNaming.*;
*
* It has no GUI, just a text frontend to keep it simple.
*
* $Id: StockClient.java,v 1.
5 2001/11/19 23:19:20
momjian Exp $
* $Id: StockClient.java,v 1.
6 2002/09/06 21:23:05
momjian Exp $
*/
public
class
StockClient
{
...
...
@@ -35,14 +35,14 @@ public class StockClient
if
(
nameServiceObj
==
null
)
{
System
.
err
.
println
(
"nameServiceObj == null"
);
return
;
return
;
}
nameService
=
org
.
omg
.
CosNaming
.
NamingContextHelper
.
narrow
(
nameServiceObj
);
if
(
nameService
==
null
)
{
System
.
err
.
println
(
"nameService == null"
);
return
;
return
;
}
// Resolve the dispenser
...
...
@@ -53,7 +53,7 @@ public class StockClient
if
(
dispenser
==
null
)
{
System
.
err
.
println
(
"dispenser == null"
);
return
;
return
;
}
// Now run the front end.
...
...
src/interfaces/jdbc/example/corba/StockDispenserImpl.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import org.omg.CosNaming.*;
/*
* This class implements the server side of the example.
*
* $Id: StockDispenserImpl.java,v 1.
4 2001/11/19 23:19:20
momjian Exp $
* $Id: StockDispenserImpl.java,v 1.
5 2002/09/06 21:23:05
momjian Exp $
*/
public
class
StockDispenserImpl
extends
stock
.
_StockDispenserImplBase
{
...
...
@@ -67,11 +67,11 @@ public class StockDispenserImpl extends stock._StockDispenserImplBase
{
stock
[
i
].
inUse
=
false
;
System
.
out
.
println
(
"Releasing slot "
+
i
);
return
;
return
;
}
}
System
.
out
.
println
(
"Reserved object not a member of this dispenser"
);
return
;
return
;
}
/*
...
...
src/interfaces/jdbc/example/corba/StockServer.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import org.omg.CosNaming.*;
/*
* This class implements the server side of the example.
*
* $Id: StockServer.java,v 1.
4 2001/11/19 23:19:20
momjian Exp $
* $Id: StockServer.java,v 1.
5 2002/09/06 21:23:05
momjian Exp $
*/
public
class
StockServer
{
...
...
@@ -29,14 +29,14 @@ public class StockServer
if
(
nameServiceObj
==
null
)
{
System
.
err
.
println
(
"nameServiceObj = null"
);
return
;
return
;
}
org
.
omg
.
CosNaming
.
NamingContext
nameService
=
org
.
omg
.
CosNaming
.
NamingContextHelper
.
narrow
(
nameServiceObj
);
if
(
nameService
==
null
)
{
System
.
err
.
println
(
"nameService = null"
);
return
;
return
;
}
// bind the dispenser into the naming service
...
...
src/interfaces/jdbc/example/psql.java
View file @
f37c1c48
...
...
@@ -82,7 +82,7 @@ public class psql
if
(
line
.
startsWith
(
"\\"
))
{
processSlashCommand
(
line
);
return
;
return
;
}
boolean
type
=
st
.
execute
(
line
);
...
...
src/interfaces/jdbc/org/postgresql/Driver.java.in
View file @
f37c1c48
...
...
@@ -109,12 +109,14 @@ public class Driver implements java.sql.Driver
{
if
((
props
=
parseURL
(
url
,
info
))
==
null
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Error in url"
+
url
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Error in url"
+
url
);
return
null
;
}
try
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"connect "
+
url
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"connect "
+
url
);
@
JDBCCONNECTCLASS
@
con
=
(@
JDBCCONNECTCLASS
@)(
Class
.
forName
(
"@JDBCCONNECTCLASS@"
).
newInstance
());
con
.
openConnection
(
host
(),
port
(),
props
,
database
(),
url
,
this
);
...
...
@@ -122,7 +124,8 @@ public class Driver implements java.sql.Driver
}
catch
(
ClassNotFoundException
ex
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"error"
,
ex
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"error"
,
ex
);
throw
new
PSQLException
(
"postgresql.jvm.version"
,
ex
);
}
catch
(
PSQLException
ex1
)
...
...
@@ -133,7 +136,8 @@ public class Driver implements java.sql.Driver
}
catch
(
Exception
ex2
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"error"
,
ex2
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"error"
,
ex2
);
throw
new
PSQLException
(
"postgresql.unusual"
,
ex2
);
}
}
...
...
src/interfaces/jdbc/org/postgresql/PGConnection.java
View file @
f37c1c48
...
...
@@ -7,7 +7,7 @@ import org.postgresql.core.Encoding;
import
org.postgresql.fastpath.Fastpath
;
import
org.postgresql.largeobject.LargeObjectManager
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.
2 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.
3 2002/09/06 21:23:05 momjian
Exp $
* This interface defines PostgreSQL extentions to the java.sql.Connection interface.
* Any java.sql.Connection object returned by the driver will also implement this
* interface
...
...
src/interfaces/jdbc/org/postgresql/PGNotification.java
View file @
f37c1c48
package
org.postgresql
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.
1 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.
2 2002/09/06 21:23:05 momjian
Exp $
* This interface defines PostgreSQL extention for Notifications
*/
public
interface
PGNotification
...
...
src/interfaces/jdbc/org/postgresql/PGStatement.java
View file @
f37c1c48
...
...
@@ -3,7 +3,7 @@ package org.postgresql;
import
java.sql.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.
4 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.
5 2002/09/06 21:23:05 momjian
Exp $
* This interface defines PostgreSQL extentions to the java.sql.Statement interface.
* Any java.sql.Statement object returned by the driver will also implement this
* interface
...
...
src/interfaces/jdbc/org/postgresql/core/Encoding.java
View file @
f37c1c48
...
...
@@ -8,7 +8,7 @@ import org.postgresql.util.*;
/*
* Converts to and from the character encoding used by the backend.
*
* $Id: Encoding.java,v 1.
5 2002/03/19 02:48:4
5 momjian Exp $
* $Id: Encoding.java,v 1.
6 2002/09/06 21:23:0
5 momjian Exp $
*/
public
class
Encoding
...
...
@@ -42,14 +42,14 @@ public class Encoding
encodings
.
put
(
"EUC_KR"
,
new
String
[]
{
"EUC_KR"
});
encodings
.
put
(
"JOHAB"
,
new
String
[]
{
"Johab"
});
encodings
.
put
(
"EUC_TW"
,
new
String
[]
{
"EUC_TW"
});
encodings
.
put
(
"SJIS"
,
new
String
[]
{
"MS932"
,
"SJIS"
});
encodings
.
put
(
"BIG5"
,
new
String
[]
{
"Big5"
,
"MS950"
,
"Cp950"
});
encodings
.
put
(
"GBK"
,
new
String
[]
{
"GBK"
,
"MS936"
});
encodings
.
put
(
"UHC"
,
new
String
[]
{
"MS949"
,
"Cp949"
,
"Cp949C"
});
encodings
.
put
(
"SJIS"
,
new
String
[]
{
"MS932"
,
"SJIS"
});
encodings
.
put
(
"BIG5"
,
new
String
[]
{
"Big5"
,
"MS950"
,
"Cp950"
});
encodings
.
put
(
"GBK"
,
new
String
[]
{
"GBK"
,
"MS936"
});
encodings
.
put
(
"UHC"
,
new
String
[]
{
"MS949"
,
"Cp949"
,
"Cp949C"
});
encodings
.
put
(
"TCVN"
,
new
String
[]
{
"Cp1258"
});
encodings
.
put
(
"WIN1256"
,
new
String
[]
{
"Cp1256"
});
encodings
.
put
(
"WIN1250"
,
new
String
[]
{
"Cp1250"
});
encodings
.
put
(
"WIN874"
,
new
String
[]
{
"MS874"
,
"Cp874"
});
encodings
.
put
(
"WIN874"
,
new
String
[]
{
"MS874"
,
"Cp874"
});
encodings
.
put
(
"WIN"
,
new
String
[]
{
"Cp1251"
});
encodings
.
put
(
"ALT"
,
new
String
[]
{
"Cp866"
});
// We prefer KOI8-U, since it is a superset of KOI8-R.
...
...
src/interfaces/jdbc/org/postgresql/core/Notification.java
View file @
f37c1c48
package
org.postgresql.core
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.
1 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.
2 2002/09/06 21:23:05 momjian
Exp $
* This is the implementation of the PGNotification interface
*/
public
class
Notification
implements
org
.
postgresql
.
PGNotification
{
public
Notification
(
String
p_name
,
int
p_pid
)
{
public
Notification
(
String
p_name
,
int
p_pid
)
{
m_name
=
p_name
;
m_pid
=
p_pid
;
}
...
...
@@ -14,14 +15,16 @@ public class Notification implements org.postgresql.PGNotification
/*
* Returns name of this notification
*/
public
String
getName
()
{
public
String
getName
()
{
return
m_name
;
}
/*
* Returns the process id of the backend process making this notification
*/
public
int
getPID
()
{
public
int
getPID
()
{
return
m_pid
;
}
...
...
src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
View file @
f37c1c48
...
...
@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
* <p>The lifetime of a QueryExecutor object is from sending the query
* until the response has been received from the backend.
*
* $Id: QueryExecutor.java,v 1.1
5 2002/09/02 03:07:36 barry
Exp $
* $Id: QueryExecutor.java,v 1.1
6 2002/09/06 21:23:05 momjian
Exp $
*/
public
class
QueryExecutor
...
...
@@ -137,7 +137,8 @@ public class QueryExecutor
try
{
pg_stream
.
SendChar
(
'Q'
);
for
(
int
i
=
0
;
i
<
m_binds
.
length
;
++
i
)
{
for
(
int
i
=
0
;
i
<
m_binds
.
length
;
++
i
)
{
if
(
m_binds
[
i
]
==
null
)
throw
new
PSQLException
(
"postgresql.prep.param"
,
new
Integer
(
i
+
1
));
pg_stream
.
Send
(
connection
.
getEncoding
().
encode
(
m_sqlFrags
[
i
]));
...
...
src/interfaces/jdbc/org/postgresql/core/StartupPacket.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.io.IOException;
/**
* Sent to the backend to initialize a newly created connection.
*
* $Id: StartupPacket.java,v 1.
1 2002/03/21 02:40:03 davec
Exp $
* $Id: StartupPacket.java,v 1.
2 2002/09/06 21:23:05 momjian
Exp $
*/
public
class
StartupPacket
...
...
@@ -22,7 +22,8 @@ public class StartupPacket
private
String
user
;
private
String
database
;
public
StartupPacket
(
int
protocolMajor
,
int
protocolMinor
,
String
user
,
String
database
)
{
public
StartupPacket
(
int
protocolMajor
,
int
protocolMinor
,
String
user
,
String
database
)
{
this
.
protocolMajor
=
protocolMajor
;
this
.
protocolMinor
=
protocolMinor
;
this
.
user
=
user
;
...
...
src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java
View file @
f37c1c48
...
...
@@ -118,7 +118,8 @@ public class Fastpath
case
'V'
:
int
l_nextChar
=
stream
.
ReceiveChar
();
if
(
l_nextChar
==
'G'
)
{
if
(
l_nextChar
==
'G'
)
{
int
sz
=
stream
.
ReceiveIntegerR
(
4
);
// Return an Integer if
if
(
resulttype
)
...
...
@@ -131,7 +132,9 @@ public class Fastpath
}
//There should be a trailing '0'
int
l_endChar
=
stream
.
ReceiveChar
();
}
else
{
}
else
{
//it must have been a '0', thus no results
}
break
;
...
...
@@ -174,7 +177,8 @@ public class Fastpath
*/
public
Object
fastpath
(
String
name
,
boolean
resulttype
,
FastpathArg
[]
args
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Fastpath: calling "
+
name
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Fastpath: calling "
+
name
);
return
fastpath
(
getID
(
name
),
resulttype
,
args
);
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
View file @
f37c1c48
...
...
@@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager;
import
org.postgresql.util.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.
7 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.
8 2002/09/06 21:23:05 momjian
Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
...
...
@@ -130,23 +130,29 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
//Read loglevel arg and set the loglevel based on this value
//in addition to setting the log level enable output to
//standard out if no other printwriter is set
String
l_logLevelProp
=
info
.
getProperty
(
"loglevel"
,
"0"
);
String
l_logLevelProp
=
info
.
getProperty
(
"loglevel"
,
"0"
);
int
l_logLevel
=
0
;
try
{
try
{
l_logLevel
=
Integer
.
parseInt
(
l_logLevelProp
);
if
(
l_logLevel
>
org
.
postgresql
.
Driver
.
DEBUG
||
l_logLevel
<
org
.
postgresql
.
Driver
.
INFO
)
{
if
(
l_logLevel
>
org
.
postgresql
.
Driver
.
DEBUG
||
l_logLevel
<
org
.
postgresql
.
Driver
.
INFO
)
{
l_logLevel
=
0
;
}
}
catch
(
Exception
l_e
)
{
}
catch
(
Exception
l_e
)
{
//invalid value for loglevel ignore
}
if
(
l_logLevel
>
0
)
{
if
(
l_logLevel
>
0
)
{
org
.
postgresql
.
Driver
.
setLogLevel
(
l_logLevel
);
enableDriverManagerLogging
();
}
//Print out the driver version number
if
(
org
.
postgresql
.
Driver
.
logInfo
)
org
.
postgresql
.
Driver
.
info
(
org
.
postgresql
.
Driver
.
getVersion
());
if
(
org
.
postgresql
.
Driver
.
logInfo
)
org
.
postgresql
.
Driver
.
info
(
org
.
postgresql
.
Driver
.
getVersion
());
// Now make the initial connection
try
...
...
@@ -205,7 +211,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
rst
[
0
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
rst
[
1
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
rst
,
0
,
2
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"Crypt salt="
+
salt
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"Crypt salt="
+
salt
);
}
// Or get the md5 password salt if there is one
...
...
@@ -217,7 +224,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
md5Salt
[
2
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
md5Salt
[
3
]
=
(
byte
)
pg_stream
.
ReceiveChar
();
salt
=
new
String
(
md5Salt
,
0
,
4
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"MD5 salt="
+
salt
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"MD5 salt="
+
salt
);
}
// now send the auth packet
...
...
@@ -227,15 +235,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break
;
case
AUTH_REQ_KRB4:
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: KRB4"
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: KRB4"
);
throw
new
PSQLException
(
"postgresql.con.kerb4"
);
case
AUTH_REQ_KRB5:
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: KRB5"
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: KRB5"
);
throw
new
PSQLException
(
"postgresql.con.kerb5"
);
case
AUTH_REQ_PASSWORD:
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: PASSWORD"
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: PASSWORD"
);
pg_stream
.
SendInteger
(
5
+
password
.
length
(),
4
);
pg_stream
.
Send
(
password
.
getBytes
());
pg_stream
.
SendInteger
(
0
,
1
);
...
...
@@ -243,7 +254,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break
;
case
AUTH_REQ_CRYPT:
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: CRYPT"
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: CRYPT"
);
String
crypted
=
UnixCrypt
.
crypt
(
salt
,
password
);
pg_stream
.
SendInteger
(
5
+
crypted
.
length
(),
4
);
pg_stream
.
Send
(
crypted
.
getBytes
());
...
...
@@ -252,7 +264,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
break
;
case
AUTH_REQ_MD5:
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: MD5"
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"postgresql: MD5"
);
byte
[]
digest
=
MD5Digest
.
encode
(
PG_USER
,
password
,
md5Salt
);
pg_stream
.
SendInteger
(
5
+
digest
.
length
,
4
);
pg_stream
.
Send
(
digest
);
...
...
@@ -280,7 +293,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
// As of protocol version 2.0, we should now receive the cancellation key and the pid
int
beresp
;
do
{
do
{
beresp
=
pg_stream
.
ReceiveChar
();
switch
(
beresp
)
{
...
...
@@ -296,10 +310,12 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
}
}
while
(
beresp
==
'N'
);
}
while
(
beresp
==
'N'
);
// Expect ReadyForQuery packet
do
{
do
{
beresp
=
pg_stream
.
ReceiveChar
();
switch
(
beresp
)
{
...
...
@@ -313,7 +329,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
default
:
throw
new
PSQLException
(
"postgresql.con.setup"
);
}
}
while
(
beresp
==
'N'
);
}
while
(
beresp
==
'N'
);
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
// otherwise it's hardcoded to 'SQL_ASCII'.
// If the backend doesn't know about multibyte we can't assume anything about the encoding
...
...
@@ -877,7 +894,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public
void
setAutoCommit
(
boolean
autoCommit
)
throws
SQLException
{
if
(
this
.
autoCommit
==
autoCommit
)
return
;
return
;
if
(
autoCommit
)
ExecSQL
(
"end"
);
else
...
...
@@ -920,7 +937,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public
void
commit
()
throws
SQLException
{
if
(
autoCommit
)
return
;
return
;
if
(
haveMinimumServerVersion
(
"7.1"
))
{
ExecSQL
(
"commit;begin;"
+
getIsolationLevelSQL
());
...
...
@@ -944,7 +961,7 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
public
void
rollback
()
throws
SQLException
{
if
(
autoCommit
)
return
;
return
;
if
(
haveMinimumServerVersion
(
"7.1"
))
{
ExecSQL
(
"rollback; begin;"
+
getIsolationLevelSQL
());
...
...
@@ -1222,8 +1239,10 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
//Because the get/setLogStream methods are deprecated in JDBC2
//we use them for JDBC1 here and override this method in the jdbc2
//version of this class
protected
void
enableDriverManagerLogging
()
{
if
(
DriverManager
.
getLogStream
()
==
null
)
{
protected
void
enableDriverManagerLogging
()
{
if
(
DriverManager
.
getLogStream
()
==
null
)
{
DriverManager
.
setLogStream
(
System
.
out
);
}
}
...
...
@@ -1313,15 +1332,18 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
};
//Methods to support postgres notifications
public
void
addNotification
(
org
.
postgresql
.
PGNotification
p_notification
)
{
public
void
addNotification
(
org
.
postgresql
.
PGNotification
p_notification
)
{
if
(
m_notifications
==
null
)
m_notifications
=
new
Vector
();
m_notifications
.
addElement
(
p_notification
);
}
public
PGNotification
[]
getNotifications
()
{
public
PGNotification
[]
getNotifications
()
{
PGNotification
[]
l_return
=
null
;
if
(
m_notifications
!=
null
)
{
if
(
m_notifications
!=
null
)
{
l_return
=
new
PGNotification
[
m_notifications
.
size
()];
m_notifications
.
copyInto
(
l_return
);
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
View file @
f37c1c48
...
...
@@ -11,12 +11,12 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
private
static
final
String
keywords
=
"abort,acl,add,aggregate,append,archive,"
+
"arch_store,backward,binary,change,cluster,"
+
"copy,database,delimiter,delimiters,do,extend,"
+
"explain,forward,heavy,index,inherits,isnull,"
+
"light,listen,load,merge,nothing,notify,"
+
"notnull,oids,purge,rename,replace,retrieve,"
+
"returns,rule,recipe,setof,stdin,stdout,store,"
+
"arch_store,backward,binary,change,cluster,"
+
"copy,database,delimiter,delimiters,do,extend,"
+
"explain,forward,heavy,index,inherits,isnull,"
+
"light,listen,load,merge,nothing,notify,"
+
"notnull,oids,purge,rename,replace,retrieve,"
+
"returns,rule,recipe,setof,stdin,stdout,store,"
+
"vacuum,verbose,version"
;
protected
AbstractJdbc1Connection
connection
;
// The connection association
...
...
@@ -42,7 +42,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
allProceduresAreCallable
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"allProceduresAreCallable"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"allProceduresAreCallable"
);
return
true
;
// For now...
}
...
...
@@ -55,7 +56,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
allTablesAreSelectable
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"allTablesAreSelectable"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"allTablesAreSelectable"
);
return
true
;
// For now...
}
...
...
@@ -68,7 +70,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getURL
()
throws
SQLException
{
String
url
=
connection
.
getURL
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getURL "
+
url
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getURL "
+
url
);
return
url
;
}
...
...
@@ -81,7 +84,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getUserName
()
throws
SQLException
{
String
userName
=
connection
.
getUserName
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getUserName "
+
userName
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getUserName "
+
userName
);
return
userName
;
}
...
...
@@ -94,7 +98,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
isReadOnly
()
throws
SQLException
{
boolean
isReadOnly
=
connection
.
isReadOnly
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"isReadOnly "
+
isReadOnly
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"isReadOnly "
+
isReadOnly
);
return
isReadOnly
;
}
...
...
@@ -107,7 +112,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
nullsAreSortedHigh
()
throws
SQLException
{
boolean
nullSortedHigh
=
connection
.
haveMinimumServerVersion
(
"7.2"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedHigh "
+
nullSortedHigh
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedHigh "
+
nullSortedHigh
);
return
nullSortedHigh
;
}
...
...
@@ -119,7 +125,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
nullsAreSortedLow
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedLow false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedLow false"
);
return
false
;
}
...
...
@@ -131,7 +138,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
nullsAreSortedAtStart
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedAtStart false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedAtStart false"
);
return
false
;
}
...
...
@@ -144,7 +152,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
nullsAreSortedAtEnd
()
throws
SQLException
{
boolean
nullsAreSortedAtEnd
=
!
connection
.
haveMinimumServerVersion
(
"7.2"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedAtEnd "
+
nullsAreSortedAtEnd
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullsAreSortedAtEnd "
+
nullsAreSortedAtEnd
);
return
nullsAreSortedAtEnd
;
}
...
...
@@ -157,7 +166,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getDatabaseProductName
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDatabaseProductName PostgresSQL"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDatabaseProductName PostgresSQL"
);
return
"PostgreSQL"
;
}
...
...
@@ -170,7 +180,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getDatabaseProductVersion
()
throws
SQLException
{
String
versionNumber
=
connection
.
getDBVersionNumber
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDatabaseProductVersion "
+
versionNumber
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDatabaseProductVersion "
+
versionNumber
);
return
versionNumber
;
}
...
...
@@ -184,7 +195,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getDriverName
()
throws
SQLException
{
String
driverName
=
"PostgreSQL Native Driver"
;
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDriverName"
+
driverName
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDriverName"
+
driverName
);
return
driverName
;
}
...
...
@@ -198,7 +210,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getDriverVersion
()
throws
SQLException
{
String
driverVersion
=
connection
.
this_driver
.
getVersion
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDriverVersion "
+
driverVersion
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getDriverVersion "
+
driverVersion
);
return
driverVersion
;
}
...
...
@@ -210,7 +223,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
int
getDriverMajorVersion
()
{
int
majorVersion
=
connection
.
this_driver
.
getMajorVersion
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getMajorVersion "
+
majorVersion
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getMajorVersion "
+
majorVersion
);
return
majorVersion
;
}
...
...
@@ -222,7 +236,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
int
getDriverMinorVersion
()
{
int
minorVersion
=
connection
.
this_driver
.
getMinorVersion
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getMinorVersion "
+
minorVersion
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getMinorVersion "
+
minorVersion
);
return
minorVersion
;
}
...
...
@@ -235,7 +250,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
usesLocalFiles
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"usesLocalFiles "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"usesLocalFiles "
+
false
);
return
false
;
}
...
...
@@ -248,7 +264,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
usesLocalFilePerTable
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"usesLocalFilePerTable "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"usesLocalFilePerTable "
+
false
);
return
false
;
}
...
...
@@ -266,7 +283,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsMixedCaseIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMixedCaseIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMixedCaseIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -278,7 +296,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesUpperCaseIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesUpperCaseIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesUpperCaseIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -290,7 +309,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesLowerCaseIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesLowerCaseIdentifiers "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesLowerCaseIdentifiers "
+
true
);
return
true
;
}
...
...
@@ -302,7 +322,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesMixedCaseIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesMixedCaseIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesMixedCaseIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -316,7 +337,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsMixedCaseQuotedIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMixedCaseQuotedIdentifiers "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMixedCaseQuotedIdentifiers "
+
true
);
return
true
;
}
...
...
@@ -328,7 +350,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesUpperCaseQuotedIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesUpperCaseQuotedIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesUpperCaseQuotedIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -340,7 +363,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesLowerCaseQuotedIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesLowerCaseQuotedIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesLowerCaseQuotedIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -352,7 +376,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
storesMixedCaseQuotedIdentifiers
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesMixedCaseQuotedIdentifiers "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"storesMixedCaseQuotedIdentifiers "
+
false
);
return
false
;
}
...
...
@@ -366,7 +391,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getIdentifierQuoteString
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getIdentifierQuoteString \""
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getIdentifierQuoteString \""
);
return
"\""
;
}
...
...
@@ -393,25 +419,29 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
String
getNumericFunctions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getNumericFunctions"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getNumericFunctions"
);
return
""
;
}
public
String
getStringFunctions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getStringFunctions"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getStringFunctions"
);
return
""
;
}
public
String
getSystemFunctions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSystemFunctions"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSystemFunctions"
);
return
""
;
}
public
String
getTimeDateFunctions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getTimeDateFunctions"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getTimeDateFunctions"
);
return
""
;
}
...
...
@@ -424,7 +454,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getSearchStringEscape
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSearchStringEscape"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSearchStringEscape"
);
return
"\\"
;
}
...
...
@@ -441,7 +472,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getExtraNameCharacters
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getExtraNameCharacters"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getExtraNameCharacters"
);
return
""
;
}
...
...
@@ -454,7 +486,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsAlterTableWithAddColumn
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsAlterTableWithAddColumn "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsAlterTableWithAddColumn "
+
true
);
return
true
;
}
...
...
@@ -467,7 +500,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsAlterTableWithDropColumn
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsAlterTableWithDropColumn "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsAlterTableWithDropColumn "
+
false
);
return
false
;
}
...
...
@@ -491,7 +525,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsColumnAliasing
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsColumnAliasing "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsColumnAliasing "
+
true
);
return
true
;
}
...
...
@@ -504,19 +539,22 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
nullPlusNonNullIsNull
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullPlusNonNullIsNull "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"nullPlusNonNullIsNull "
+
true
);
return
true
;
}
public
boolean
supportsConvert
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsConvert "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsConvert "
+
false
);
return
false
;
}
public
boolean
supportsConvert
(
int
fromType
,
int
toType
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsConvert "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsConvert "
+
false
);
return
false
;
}
...
...
@@ -529,7 +567,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsTableCorrelationNames
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsTableCorrelationNames "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsTableCorrelationNames "
+
true
);
return
true
;
}
...
...
@@ -542,7 +581,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsDifferentTableCorrelationNames
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsDifferentTableCorrelationNames "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsDifferentTableCorrelationNames "
+
false
);
return
false
;
}
...
...
@@ -556,7 +596,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsExpressionsInOrderBy
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsExpressionsInOrderBy "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsExpressionsInOrderBy "
+
true
);
return
true
;
}
...
...
@@ -569,7 +610,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsOrderByUnrelated
()
throws
SQLException
{
boolean
supportsOrderByUnrelated
=
connection
.
haveMinimumServerVersion
(
"6.4"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsOrderByUnrelated "
+
supportsOrderByUnrelated
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsOrderByUnrelated "
+
supportsOrderByUnrelated
);
return
supportsOrderByUnrelated
;
}
...
...
@@ -582,7 +624,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsGroupBy
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupBy "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupBy "
+
true
);
return
true
;
}
...
...
@@ -595,7 +638,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsGroupByUnrelated
()
throws
SQLException
{
boolean
supportsGroupByUnrelated
=
connection
.
haveMinimumServerVersion
(
"6.4"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupByUnrelated "
+
supportsGroupByUnrelated
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupByUnrelated "
+
supportsGroupByUnrelated
);
return
supportsGroupByUnrelated
;
}
...
...
@@ -612,7 +656,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsGroupByBeyondSelect
()
throws
SQLException
{
boolean
supportsGroupByBeyondSelect
=
connection
.
haveMinimumServerVersion
(
"6.4"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupByUnrelated "
+
supportsGroupByBeyondSelect
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsGroupByUnrelated "
+
supportsGroupByBeyondSelect
);
return
supportsGroupByBeyondSelect
;
}
...
...
@@ -626,7 +671,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsLikeEscapeClause
()
throws
SQLException
{
boolean
supportsLikeEscapeClause
=
connection
.
haveMinimumServerVersion
(
"7.1"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsLikeEscapeClause "
+
supportsLikeEscapeClause
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsLikeEscapeClause "
+
supportsLikeEscapeClause
);
return
supportsLikeEscapeClause
;
}
...
...
@@ -640,7 +686,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsMultipleResultSets
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMultipleResultSets "
+
false
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMultipleResultSets "
+
false
);
return
false
;
}
...
...
@@ -654,7 +701,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsMultipleTransactions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMultipleTransactions "
+
true
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMultipleTransactions "
+
true
);
return
true
;
}
...
...
@@ -670,7 +718,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsNonNullableColumns
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsNonNullableColumns true"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsNonNullableColumns true"
);
return
true
;
}
...
...
@@ -688,7 +737,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsMinimumSQLGrammar
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMinimumSQLGrammar TRUE"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsMinimumSQLGrammar TRUE"
);
return
true
;
}
...
...
@@ -701,7 +751,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCoreSQLGrammar
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCoreSQLGrammar FALSE "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCoreSQLGrammar FALSE "
);
return
false
;
}
...
...
@@ -715,7 +766,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsExtendedSQLGrammar
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsExtendedSQLGrammar FALSE"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsExtendedSQLGrammar FALSE"
);
return
false
;
}
...
...
@@ -734,7 +786,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsANSI92EntryLevelSQL
()
throws
SQLException
{
boolean
schemas
=
connection
.
haveMinimumServerVersion
(
"7.3"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92EntryLevelSQL "
+
schemas
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92EntryLevelSQL "
+
schemas
);
return
schemas
;
}
...
...
@@ -747,7 +800,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsANSI92IntermediateSQL
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92IntermediateSQL false "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92IntermediateSQL false "
);
return
false
;
}
...
...
@@ -759,7 +813,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsANSI92FullSQL
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92FullSQL false "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsANSI92FullSQL false "
);
return
false
;
}
...
...
@@ -772,7 +827,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsIntegrityEnhancementFacility
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsIntegrityEnhancementFacility false "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsIntegrityEnhancementFacility false "
);
return
false
;
}
...
...
@@ -785,7 +841,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsOuterJoins
()
throws
SQLException
{
boolean
supportsOuterJoins
=
connection
.
haveMinimumServerVersion
(
"7.1"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsOuterJoins "
+
supportsOuterJoins
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsOuterJoins "
+
supportsOuterJoins
);
return
supportsOuterJoins
;
}
...
...
@@ -798,7 +855,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsFullOuterJoins
()
throws
SQLException
{
boolean
supportsFullOuterJoins
=
connection
.
haveMinimumServerVersion
(
"7.1"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsFullOuterJoins "
+
supportsFullOuterJoins
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsFullOuterJoins "
+
supportsFullOuterJoins
);
return
supportsFullOuterJoins
;
}
...
...
@@ -811,7 +869,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
public
boolean
supportsLimitedOuterJoins
()
throws
SQLException
{
boolean
supportsLimitedOuterJoins
=
connection
.
haveMinimumServerVersion
(
"7.1"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsFullOuterJoins "
+
supportsLimitedOuterJoins
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsFullOuterJoins "
+
supportsLimitedOuterJoins
);
return
supportsLimitedOuterJoins
;
}
...
...
@@ -825,7 +884,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getSchemaTerm
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSchemaTerm schema"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getSchemaTerm schema"
);
return
"schema"
;
}
...
...
@@ -838,7 +898,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getProcedureTerm
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getProcedureTerm function "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getProcedureTerm function "
);
return
"function"
;
}
...
...
@@ -850,7 +911,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
String
getCatalogTerm
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getCatalogTerm database "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getCatalogTerm database "
);
return
"database"
;
}
...
...
@@ -865,7 +927,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
// return true here; we return false for every other catalog function
// so it won't matter what we return here D.C.
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"isCatalogAtStart not implemented"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"isCatalogAtStart not implemented"
);
return
true
;
}
...
...
@@ -879,7 +942,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
// Give them something to work with here
// everything else returns false so it won't matter what we return here D.C.
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getCatalogSeparator not implemented "
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getCatalogSeparator not implemented "
);
return
"."
;
}
...
...
@@ -891,7 +955,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsSchemasInDataManipulation
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInDataManipulation false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInDataManipulation false"
);
return
false
;
}
...
...
@@ -903,7 +968,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsSchemasInProcedureCalls
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInProcedureCalls false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInProcedureCalls false"
);
return
false
;
}
...
...
@@ -917,7 +983,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
boolean
schemas
=
connection
.
haveMinimumServerVersion
(
"7.3"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInTableDefinitions "
+
schemas
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInTableDefinitions "
+
schemas
);
return
schemas
;
}
...
...
@@ -929,7 +996,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsSchemasInIndexDefinitions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInIndexDefinitions false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInIndexDefinitions false"
);
return
false
;
}
...
...
@@ -941,7 +1009,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsSchemasInPrivilegeDefinitions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInPrivilegeDefinitions false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsSchemasInPrivilegeDefinitions false"
);
return
false
;
}
...
...
@@ -953,7 +1022,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCatalogsInDataManipulation
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInDataManipulation false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInDataManipulation false"
);
return
false
;
}
...
...
@@ -965,7 +1035,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCatalogsInProcedureCalls
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInDataManipulation false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInDataManipulation false"
);
return
false
;
}
...
...
@@ -977,7 +1048,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCatalogsInTableDefinitions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInTableDefinitions false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInTableDefinitions false"
);
return
false
;
}
...
...
@@ -989,7 +1061,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCatalogsInIndexDefinitions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInIndexDefinitions false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInIndexDefinitions false"
);
return
false
;
}
...
...
@@ -1001,7 +1074,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsCatalogsInPrivilegeDefinitions
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInPrivilegeDefinitions false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsCatalogsInPrivilegeDefinitions false"
);
return
false
;
}
...
...
@@ -1014,7 +1088,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsPositionedDelete
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsPositionedDelete false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsPositionedDelete false"
);
return
false
;
// For now...
}
...
...
@@ -1026,7 +1101,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
*/
public
boolean
supportsPositionedUpdate
()
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsPositionedUpdate false"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"supportsPositionedUpdate false"
);
return
false
;
// For now...
}
...
...
@@ -2184,7 +2260,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
byte
[][]
tuple
=
new
byte
[
8
][
0
];
tuple
[
0
]
=
tuple
[
1
]
=
""
.
getBytes
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"relname=\""
+
r
.
getString
(
1
)
+
"\" relacl=\""
+
r
.
getString
(
2
)
+
"\""
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"relname=\""
+
r
.
getString
(
1
)
+
"\" relacl=\""
+
r
.
getString
(
2
)
+
"\""
);
// For now, don't add to the result as relacl needs to be processed.
//v.addElement(tuple);
...
...
@@ -2247,7 +2324,8 @@ public abstract class AbstractJdbc1DatabaseMetaData
{
byte
[][]
tuple
=
new
byte
[
8
][
0
];
tuple
[
0
]
=
tuple
[
1
]
=
""
.
getBytes
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"relname=\""
+
r
.
getString
(
1
)
+
"\" relacl=\""
+
r
.
getString
(
2
)
+
"\""
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"relname=\""
+
r
.
getString
(
1
)
+
"\" relacl=\""
+
r
.
getString
(
2
)
+
"\""
);
// For now, don't add to the result as relacl needs to be processed.
//v.addElement(tuple);
...
...
@@ -2385,7 +2463,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
);
}
/*
/*
SELECT
c.relname as primary,
c2.relname as foreign,
...
...
@@ -2399,7 +2477,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
t.tgnargs,t.tgargs,
p1.proname as updaterule,
p2.proname as deleterule
FROM
FROM
pg_trigger t,
pg_trigger t1,
pg_class c,
...
...
@@ -2412,7 +2490,7 @@ FROM
pg_index ip,
pg_attribute af,
pg_attribute ap
WHERE
WHERE
(t.tgrelid=c.oid
AND t.tgisconstraint
AND t.tgconstrrelid=c2.oid
...
...
@@ -2440,8 +2518,8 @@ WHERE
and ipc.oid=ap.attrelid
and ip.indisprimary)
*/
/**
*/
/**
*
* @param catalog
* @param schema
...
...
@@ -2526,21 +2604,21 @@ WHERE
+
(
primaryTable
!=
null
?
"frelname"
:
"prelname"
)
+
",keyseq"
);
// returns the following columns
// and some example data with a table defined as follows
// returns the following columns
// and some example data with a table defined as follows
// create table people ( id int primary key);
// create table policy ( id int primary key);
// create table users ( id int primary key, people_id int references people(id), policy_id int references policy(id))
// create table people ( id int primary key);
// create table policy ( id int primary key);
// create table users ( id int primary key, people_id int references people(id), policy_id int references policy(id))
// prelname | frelname | tgconstrname | keyseq | fkeyName
| tgdeferrable | tginitdeferred
// 1 | 2 | 3 | 4 | 5 | 6 |
7
// prelname | frelname | tgconstrname | keyseq | fkeyName
| tgdeferrable | tginitdeferred
// 1 | 2 | 3 | 4 | 5 | 6 |
7
// people | users | <unnamed> | 1 | people_pkey | f |
f
// people | users | <unnamed> | 1 | people_pkey | f |
f
// | tgnargs | tgargs | updaterule
| deleterule
// | 8 | 9 | 10 |
11
// | 6
| <unnamed>\000users\000people\000UNSPECIFIED\000people_id\000id\000 | RI_FKey_noaction_upd | RI_FKey_noaction_del
// | tgnargs | tgargs | updaterule
| deleterule
// | 8 | 9 | 10 |
11
// | 6
| <unnamed>\000users\000people\000UNSPECIFIED\000people_id\000id\000 | RI_FKey_noaction_upd | RI_FKey_noaction_del
Vector
tuples
=
new
Vector
();
...
...
@@ -2596,8 +2674,8 @@ WHERE
// Parse the tgargs data
String
fkeyColumn
=
""
;
String
pkeyColumn
=
""
;
String
fkeyColumn
=
""
;
String
pkeyColumn
=
""
;
// Note, I am guessing at most of this, but it should be close
...
...
@@ -2616,8 +2694,9 @@ WHERE
StringTokenizer
st
=
new
StringTokenizer
(
targs
,
"\\000"
);
int
advance
=
4
+
(
keySequence
-
1
)
*
2
;
for
(
int
i
=
0
;
st
.
hasMoreTokens
()
&&
i
<
advance
;
i
++
)
st
.
nextToken
();
// advance to the key column of interest
int
advance
=
4
+
(
keySequence
-
1
)
*
2
;
for
(
int
i
=
0
;
st
.
hasMoreTokens
()
&&
i
<
advance
;
i
++
)
st
.
nextToken
();
// advance to the key column of interest
if
(
st
.
hasMoreTokens
()
)
{
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
View file @
f37c1c48
...
...
@@ -13,7 +13,7 @@ import org.postgresql.largeobject.*;
import
org.postgresql.util.PGbytea
;
import
org.postgresql.util.PSQLException
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.
5 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.
6 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
...
...
@@ -39,7 +39,7 @@ public abstract class AbstractJdbc1ResultSet
protected
ResultSet
next
=
null
;
protected
StringBuffer
sbuf
=
null
;
public
byte
[][]
rowBuffer
=
null
;
public
byte
[][]
rowBuffer
=
null
;
public
AbstractJdbc1ResultSet
(
org
.
postgresql
.
PGConnection
conn
,
Statement
statement
,
Field
[]
fields
,
Vector
tuples
,
String
status
,
int
updateCount
,
long
insertOID
,
boolean
binaryCursor
)
...
...
@@ -67,8 +67,8 @@ public abstract class AbstractJdbc1ResultSet
this_row
=
(
byte
[][])
rows
.
elementAt
(
current_row
);
rowBuffer
=
new
byte
[
this_row
.
length
][];
System
.
arraycopy
(
this_row
,
0
,
rowBuffer
,
0
,
this_row
.
length
);
rowBuffer
=
new
byte
[
this_row
.
length
][];
System
.
arraycopy
(
this_row
,
0
,
rowBuffer
,
0
,
this_row
.
length
);
return
true
;
}
...
...
@@ -230,12 +230,12 @@ public abstract class AbstractJdbc1ResultSet
public
Time
getTime
(
int
columnIndex
)
throws
SQLException
{
return
toTime
(
getString
(
columnIndex
),
(
java
.
sql
.
ResultSet
)
this
,
fields
[
columnIndex
-
1
].
getPGType
()
);
return
toTime
(
getString
(
columnIndex
),
(
java
.
sql
.
ResultSet
)
this
,
fields
[
columnIndex
-
1
].
getPGType
()
);
}
public
Timestamp
getTimestamp
(
int
columnIndex
)
throws
SQLException
{
return
toTimestamp
(
getString
(
columnIndex
),
(
java
.
sql
.
ResultSet
)
this
,
fields
[
columnIndex
-
1
].
getPGType
()
);
return
toTimestamp
(
getString
(
columnIndex
),
(
java
.
sql
.
ResultSet
)
this
,
fields
[
columnIndex
-
1
].
getPGType
()
);
}
public
InputStream
getAsciiStream
(
int
columnIndex
)
throws
SQLException
...
...
@@ -423,7 +423,8 @@ public abstract class AbstractJdbc1ResultSet
warnings
=
null
;
}
public
void
addWarnings
(
SQLWarning
warnings
)
{
public
void
addWarnings
(
SQLWarning
warnings
)
{
if
(
this
.
warnings
!=
null
)
this
.
warnings
.
setNextWarning
(
warnings
);
else
...
...
@@ -660,8 +661,10 @@ public abstract class AbstractJdbc1ResultSet
protected
void
checkResultSet
(
int
column
)
throws
SQLException
{
if
(
this_row
==
null
)
throw
new
PSQLException
(
"postgresql.res.nextrequired"
);
if
(
column
<
1
||
column
>
fields
.
length
)
throw
new
PSQLException
(
"postgresql.res.colrange"
);
if
(
this_row
==
null
)
throw
new
PSQLException
(
"postgresql.res.nextrequired"
);
if
(
column
<
1
||
column
>
fields
.
length
)
throw
new
PSQLException
(
"postgresql.res.colrange"
);
}
//----------------- Formatting Methods -------------------
...
...
@@ -789,23 +792,31 @@ public abstract class AbstractJdbc1ResultSet
return
null
;
// SQL NULL
try
{
if
(
s
.
length
()
==
8
)
{
if
(
s
.
length
()
==
8
)
{
//value is a time value
return
java
.
sql
.
Time
.
valueOf
(
s
);
}
else
if
(
s
.
indexOf
(
"."
)
==
8
)
{
}
else
if
(
s
.
indexOf
(
"."
)
==
8
)
{
//value is a time value with fractional seconds
java
.
sql
.
Time
l_time
=
java
.
sql
.
Time
.
valueOf
(
s
.
substring
(
0
,
8
));
java
.
sql
.
Time
l_time
=
java
.
sql
.
Time
.
valueOf
(
s
.
substring
(
0
,
8
));
String
l_strMillis
=
s
.
substring
(
9
);
if
(
l_strMillis
.
length
()
>
3
)
l_strMillis
=
l_strMillis
.
substring
(
0
,
3
);
l_strMillis
=
l_strMillis
.
substring
(
0
,
3
);
int
l_millis
=
Integer
.
parseInt
(
l_strMillis
);
if
(
l_millis
<
10
)
{
if
(
l_millis
<
10
)
{
l_millis
=
l_millis
*
100
;
}
else
if
(
l_millis
<
100
)
{
}
else
if
(
l_millis
<
100
)
{
l_millis
=
l_millis
*
10
;
}
return
new
java
.
sql
.
Time
(
l_time
.
getTime
()
+
l_millis
);
}
else
{
}
else
{
//value is a timestamp
return
new
java
.
sql
.
Time
(
toTimestamp
(
s
,
resultSet
,
pgDataType
).
getTime
());
}
...
...
@@ -847,12 +858,14 @@ public abstract class AbstractJdbc1ResultSet
synchronized
(
rs
)
{
SimpleDateFormat
df
=
null
;
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"the data from the DB is "
+
s
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
"the data from the DB is "
+
s
);
// If first time, create the buffer, otherwise clear it.
if
(
rs
.
sbuf
==
null
)
rs
.
sbuf
=
new
StringBuffer
(
32
);
else
{
else
{
rs
.
sbuf
.
setLength
(
0
);
}
...
...
@@ -880,7 +893,8 @@ public abstract class AbstractJdbc1ResultSet
if
(
i
<
24
)
rs
.
sbuf
.
append
(
c
);
c
=
s
.
charAt
(
i
++);
}
while
(
i
<
slen
&&
Character
.
isDigit
(
c
));
}
while
(
i
<
slen
&&
Character
.
isDigit
(
c
));
// If there wasn't at least 3 digits we should add some zeros
// to make up the 3 digits we tell java to expect.
...
...
@@ -913,10 +927,13 @@ public abstract class AbstractJdbc1ResultSet
{
// Just found fractional seconds but no timezone.
//If timestamptz then we use GMT, else local timezone
if
(
pgDataType
.
equals
(
"timestamptz"
))
{
if
(
pgDataType
.
equals
(
"timestamptz"
))
{
rs
.
sbuf
.
append
(
" GMT"
);
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss.SSS z"
);
}
else
{
}
else
{
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss.SSS"
);
}
}
...
...
@@ -925,10 +942,13 @@ public abstract class AbstractJdbc1ResultSet
{
// No tz or fractional second info.
//If timestamptz then we use GMT, else local timezone
if
(
pgDataType
.
equals
(
"timestamptz"
))
{
if
(
pgDataType
.
equals
(
"timestamptz"
))
{
rs
.
sbuf
.
append
(
" GMT"
);
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss z"
);
}
else
{
}
else
{
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
}
}
...
...
@@ -952,7 +972,8 @@ public abstract class AbstractJdbc1ResultSet
try
{
// All that's left is to parse the string and return the ts.
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
""
+
df
.
parse
(
rs
.
sbuf
.
toString
()).
getTime
()
);
if
(
org
.
postgresql
.
Driver
.
logDebug
)
org
.
postgresql
.
Driver
.
debug
(
""
+
df
.
parse
(
rs
.
sbuf
.
toString
()).
getTime
()
);
return
new
Timestamp
(
df
.
parse
(
rs
.
sbuf
.
toString
()).
getTime
());
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSetMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
View file @
f37c1c48
...
...
@@ -8,7 +8,7 @@ import java.util.Vector;
import
org.postgresql.largeobject.*
;
import
org.postgresql.util.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.
6 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.
7 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...
...
@@ -79,12 +79,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
parseSqlStmt
(
p_sql
);
// this allows Callable stmt to override
}
protected
void
parseSqlStmt
(
String
p_sql
)
throws
SQLException
{
protected
void
parseSqlStmt
(
String
p_sql
)
throws
SQLException
{
String
l_sql
=
p_sql
;
l_sql
=
replaceProcessing
(
l_sql
);
if
(
this
instanceof
CallableStatement
)
{
if
(
this
instanceof
CallableStatement
)
{
l_sql
=
modifyJdbcCall
(
l_sql
);
}
...
...
@@ -213,7 +215,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{
if
(
isFunction
&&
!
returnTypeSet
)
throw
new
PSQLException
(
"postgresql.call.noreturntype"
);
if
(
isFunction
)
{
// set entry 1 to dummy entry..
if
(
isFunction
)
{
// set entry 1 to dummy entry..
m_binds
[
0
]
=
""
;
// dummy entry which ensured that no one overrode
m_bindTypes
[
0
]
=
PG_TEXT
;
// and calls to setXXX (2,..) really went to first arg in a function call..
...
...
@@ -222,6 +225,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
// New in 7.1, if we have a previous resultset then force it to close
// This brings us nearer to compliance, and helps memory management.
// Internal stuff will call ExecSQL directly, bypassing this.
if
(
result
!=
null
)
{
java
.
sql
.
ResultSet
rs
=
getResultSet
();
...
...
@@ -230,27 +234,34 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
}
//Use server prepared statements if directed
if
(
m_useServerPrepare
)
{
if
(
m_statementName
==
null
)
{
if
(
m_useServerPrepare
)
{
if
(
m_statementName
==
null
)
{
m_statementName
=
"JDBC_STATEMENT_"
+
m_preparedCount
++;
m_origSqlFragments
=
new
String
[
m_sqlFragments
.
length
];
m_executeSqlFragments
=
new
String
[
m_sqlFragments
.
length
];
System
.
arraycopy
(
m_sqlFragments
,
0
,
m_origSqlFragments
,
0
,
m_sqlFragments
.
length
);
m_executeSqlFragments
[
0
]
=
"EXECUTE "
+
m_statementName
;
if
(
m_sqlFragments
.
length
>
1
)
{
if
(
m_sqlFragments
.
length
>
1
)
{
m_executeSqlFragments
[
0
]
=
m_executeSqlFragments
[
0
]
+
"("
;
for
(
int
i
=
1
;
i
<
m_bindTypes
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
m_bindTypes
.
length
;
i
++)
{
m_executeSqlFragments
[
i
]
=
", "
;
}
m_executeSqlFragments
[
m_bindTypes
.
length
]
=
")"
;
}
synchronized
(
sbuf
)
{
synchronized
(
sbuf
)
{
sbuf
.
setLength
(
0
);
sbuf
.
append
(
"PREPARE "
);
sbuf
.
append
(
m_statementName
);
if
(
m_origSqlFragments
.
length
>
1
)
{
if
(
m_origSqlFragments
.
length
>
1
)
{
sbuf
.
append
(
"("
);
for
(
int
i
=
0
;
i
<
m_bindTypes
.
length
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
m_bindTypes
.
length
-
1
;
i
++)
{
sbuf
.
append
(
m_bindTypes
[
i
]);
sbuf
.
append
(
", "
);
}
...
...
@@ -259,7 +270,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
}
sbuf
.
append
(
" AS "
);
sbuf
.
append
(
m_origSqlFragments
[
0
]);
for
(
int
i
=
1
;
i
<
m_origSqlFragments
.
length
;
i
++)
{
for
(
int
i
=
1
;
i
<
m_origSqlFragments
.
length
;
i
++)
{
sbuf
.
append
(
" $"
);
sbuf
.
append
(
i
);
sbuf
.
append
(
" "
);
...
...
@@ -272,7 +284,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
System
.
arraycopy
(
m_executeSqlFragments
,
1
,
m_sqlFragments
,
1
,
m_sqlFragments
.
length
-
1
);
}
}
else
{
}
else
{
m_sqlFragments
=
m_executeSqlFragments
;
}
}
...
...
@@ -281,7 +295,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
result
=
((
AbstractJdbc1Connection
)
connection
).
ExecSQL
(
m_sqlFragments
,
m_binds
,
(
java
.
sql
.
Statement
)
this
);
//If we are executing a callable statement function set the return data
if
(
isFunction
)
{
if
(
isFunction
)
{
if
(!((
AbstractJdbc1ResultSet
)
result
).
reallyResultSet
())
throw
new
PSQLException
(
"postgresql.call.noreturnval"
);
if
(!
result
.
next
())
...
...
@@ -291,10 +306,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if
(
columnType
!=
functionReturnType
)
throw
new
PSQLException
(
"postgresql.call.wrongrtntype"
,
new
Object
[]{
"java.sql.Types="
+
columnType
,
"java.sql.Types="
+
functionReturnType
});
"java.sql.Types="
+
columnType
,
"java.sql.Types="
+
functionReturnType
});
result
.
close
();
return
true
;
}
else
{
}
else
{
return
(
result
!=
null
&&
((
AbstractJdbc1ResultSet
)
result
).
reallyResultSet
());
}
}
...
...
@@ -565,7 +582,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
*/
protected
String
replaceProcessing
(
String
p_sql
)
{
if
(
replaceProcessingEnabled
)
{
if
(
replaceProcessingEnabled
)
{
// Since escape codes can only appear in SQL CODE, we keep track
// of if we enter a string or not.
StringBuffer
newsql
=
new
StringBuffer
(
p_sql
.
length
());
...
...
@@ -626,7 +644,9 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
}
return
newsql
.
toString
();
}
else
{
}
else
{
return
p_sql
;
}
}
...
...
@@ -716,7 +736,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
Integer
.
toString
(
x
)
+
"'"
,
PG_INT2
);
bind
(
parameterIndex
,
"'"
+
Integer
.
toString
(
x
)
+
"'"
,
PG_INT2
);
}
/*
...
...
@@ -745,7 +765,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
Long
.
toString
(
x
)+
"'"
,
PG_INT8
);
bind
(
parameterIndex
,
"'"
+
Long
.
toString
(
x
)
+
"'"
,
PG_INT8
);
}
/*
...
...
@@ -761,7 +781,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
Float
.
toString
(
x
)+
"'"
,
PG_FLOAT
);
bind
(
parameterIndex
,
"'"
+
Float
.
toString
(
x
)
+
"'"
,
PG_FLOAT
);
}
/*
...
...
@@ -777,7 +797,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
Double
.
toString
(
x
)+
"'"
,
PG_DOUBLE
);
bind
(
parameterIndex
,
"'"
+
Double
.
toString
(
x
)
+
"'"
,
PG_DOUBLE
);
}
/*
...
...
@@ -798,7 +818,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
x
.
toString
()+
"'"
,
PG_NUMERIC
);
bind
(
parameterIndex
,
"'"
+
x
.
toString
()
+
"'"
,
PG_NUMERIC
);
}
}
...
...
@@ -959,52 +979,69 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
sbuf
.
append
(
l_year
);
sbuf
.
append
(
'-'
);
int
l_month
=
x
.
getMonth
()
+
1
;
if
(
l_month
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_month
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_month
);
sbuf
.
append
(
'-'
);
int
l_day
=
x
.
getDate
();
if
(
l_day
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_day
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_day
);
sbuf
.
append
(
' '
);
int
l_hours
=
x
.
getHours
();
if
(
l_hours
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_hours
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_hours
);
sbuf
.
append
(
':'
);
int
l_minutes
=
x
.
getMinutes
();
if
(
l_minutes
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_minutes
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_minutes
);
sbuf
.
append
(
':'
);
int
l_seconds
=
x
.
getSeconds
();
if
(
l_seconds
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_seconds
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_seconds
);
// Make decimal from nanos.
char
[]
l_decimal
=
{
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
};
char
[]
l_decimal
=
{
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
,
'0'
};
char
[]
l_nanos
=
Integer
.
toString
(
x
.
getNanos
()).
toCharArray
();
System
.
arraycopy
(
l_nanos
,
0
,
l_decimal
,
l_decimal
.
length
-
l_nanos
.
length
,
l_nanos
.
length
);
sbuf
.
append
(
'.'
);
if
(
connection
.
haveMinimumServerVersion
(
"7.2"
))
{
sbuf
.
append
(
l_decimal
,
0
,
6
);
}
else
{
if
(
connection
.
haveMinimumServerVersion
(
"7.2"
))
{
sbuf
.
append
(
l_decimal
,
0
,
6
);
}
else
{
// Because 7.1 include bug that "hh:mm:59.999" becomes "hh:mm:60.00".
sbuf
.
append
(
l_decimal
,
0
,
2
);
sbuf
.
append
(
l_decimal
,
0
,
2
);
}
//add timezone offset
int
l_offset
=
-(
x
.
getTimezoneOffset
());
int
l_houros
=
l_offset
/
60
;
if
(
l_houros
>=
0
)
{
int
l_houros
=
l_offset
/
60
;
if
(
l_houros
>=
0
)
{
sbuf
.
append
(
'+'
);
}
else
{
}
else
{
sbuf
.
append
(
'-'
);
}
if
(
l_houros
>
-
10
&&
l_houros
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_houros
>=
0
)
{
if
(
l_houros
>
-
10
&&
l_houros
<
10
)
sbuf
.
append
(
'0'
);
if
(
l_houros
>=
0
)
{
sbuf
.
append
(
l_houros
);
}
else
{
sbuf
.
append
(-
l_houros
);
}
int
l_minos
=
l_offset
-
(
l_houros
*
60
);
if
(
l_minos
!=
0
)
{
if
(
l_minos
<
10
)
sbuf
.
append
(
'0'
);
else
{
sbuf
.
append
(
-
l_houros
);
}
int
l_minos
=
l_offset
-
(
l_houros
*
60
);
if
(
l_minos
!=
0
)
{
if
(
l_minos
<
10
)
sbuf
.
append
(
'0'
);
sbuf
.
append
(
l_minos
);
}
sbuf
.
append
(
"'"
);
...
...
@@ -1206,7 +1243,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{
int
i
;
for
(
i
=
0
;
i
<
m_binds
.
length
;
i
++)
{
for
(
i
=
0
;
i
<
m_binds
.
length
;
i
++)
{
m_binds
[
i
]
=
null
;
m_bindTypes
[
i
]
=
null
;
}
...
...
@@ -1236,7 +1274,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if
(
x
==
null
)
{
setNull
(
parameterIndex
,
Types
.
OTHER
);
return
;
return
;
}
switch
(
targetSqlType
)
{
...
...
@@ -1257,7 +1295,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
//Note this should be fixed
//as soon as the backend correctly supports int8 type
//comparisons
bind
(
parameterIndex
,
"'"
+
x
.
toString
()+
"'"
,
PG_NUMERIC
);
bind
(
parameterIndex
,
"'"
+
x
.
toString
()
+
"'"
,
PG_NUMERIC
);
break
;
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
...
...
@@ -1311,7 +1349,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if
(
x
==
null
)
{
setNull
(
parameterIndex
,
Types
.
OTHER
);
return
;
return
;
}
if
(
x
instanceof
String
)
setString
(
parameterIndex
,
(
String
)
x
);
...
...
@@ -1440,7 +1478,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
boolean
getBoolean
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
BIT
,
"Boolean"
);
if
(
callResult
==
null
)
return
false
;
if
(
callResult
==
null
)
return
false
;
return
((
Boolean
)
callResult
).
booleanValue
();
}
...
...
@@ -1454,7 +1493,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
byte
getByte
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
TINYINT
,
"Byte"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
(
byte
)((
Integer
)
callResult
).
intValue
();
}
...
...
@@ -1468,7 +1508,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
short
getShort
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
SMALLINT
,
"Short"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
(
short
)((
Integer
)
callResult
).
intValue
();
}
...
...
@@ -1483,7 +1524,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
int
getInt
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
INTEGER
,
"Int"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
((
Integer
)
callResult
).
intValue
();
}
...
...
@@ -1497,7 +1539,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
long
getLong
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
BIGINT
,
"Long"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
((
Long
)
callResult
).
longValue
();
}
...
...
@@ -1511,7 +1554,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
float
getFloat
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
REAL
,
"Float"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
((
Float
)
callResult
).
floatValue
();
}
...
...
@@ -1525,7 +1569,8 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
double
getDouble
(
int
parameterIndex
)
throws
SQLException
{
checkIndex
(
parameterIndex
,
Types
.
DOUBLE
,
"Double"
);
if
(
callResult
==
null
)
return
0
;
if
(
callResult
==
null
)
return
0
;
return
((
Double
)
callResult
).
doubleValue
();
}
...
...
@@ -1701,20 +1746,25 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
* select <some_function> (?, [?, ...]) as result
*
*/
private
String
modifyJdbcCall
(
String
p_sql
)
throws
SQLException
{
private
String
modifyJdbcCall
(
String
p_sql
)
throws
SQLException
{
// syntax checking is not complete only a few basics :(
originalSql
=
p_sql
;
// save for error msgs..
String
l_sql
=
p_sql
;
int
index
=
l_sql
.
indexOf
(
"="
);
// is implied func or proc?
boolean
isValid
=
true
;
if
(
index
!=
-
1
)
{
if
(
index
!=
-
1
)
{
isFunction
=
true
;
isValid
=
l_sql
.
indexOf
(
"?"
)
<
index
;
// ? before =
}
l_sql
=
l_sql
.
trim
();
if
(
l_sql
.
startsWith
(
"{"
)
&&
l_sql
.
endsWith
(
"}"
))
{
l_sql
=
l_sql
.
substring
(
1
,
l_sql
.
length
()
-
1
);
}
else
isValid
=
false
;
if
(
l_sql
.
startsWith
(
"{"
)
&&
l_sql
.
endsWith
(
"}"
))
{
l_sql
=
l_sql
.
substring
(
1
,
l_sql
.
length
()
-
1
);
}
else
isValid
=
false
;
index
=
l_sql
.
indexOf
(
"call"
);
if
(
index
==
-
1
||
!
isValid
)
throw
new
PSQLException
(
"postgresql.call.malformed"
,
...
...
@@ -1739,19 +1789,21 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
/** helperfunction for the getXXX calls to check isFunction and index == 1
*/
protected
void
checkIndex
(
int
parameterIndex
,
int
type
,
String
getName
)
throws
SQLException
{
throws
SQLException
{
checkIndex
(
parameterIndex
);
if
(
type
!=
this
.
testReturn
)
throw
new
PSQLException
(
"postgresql.call.wrongget"
,
new
Object
[]{
"java.sql.Types="
+
testReturn
,
new
Object
[]{
"java.sql.Types="
+
testReturn
,
getName
,
"java.sql.Types="
+
type
});
"java.sql.Types="
+
type
});
}
/** helperfunction for the getXXX calls to check isFunction and index == 1
* @param parameterIndex index of getXXX (index)
* check to make sure is a function and index == 1
*/
private
void
checkIndex
(
int
parameterIndex
)
throws
SQLException
{
private
void
checkIndex
(
int
parameterIndex
)
throws
SQLException
{
if
(!
isFunction
)
throw
new
PSQLException
(
"postgresql.call.noreturntype"
);
if
(
parameterIndex
!=
1
)
...
...
@@ -1760,11 +1812,13 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public
void
setUseServerPrepare
(
boolean
flag
)
{
public
void
setUseServerPrepare
(
boolean
flag
)
{
m_useServerPrepare
=
flag
;
}
public
boolean
isUseServerPrepare
()
{
public
boolean
isUseServerPrepare
()
{
return
m_useServerPrepare
;
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Connection.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.sql.*;
import
org.postgresql.Field
;
import
org.postgresql.util.PSQLException
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.
4 2002/07/26 05:29:35 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Connection.java,v 1.
5 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Connection interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Connection
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import java.sql.*;
import
java.util.Vector
;
import
org.postgresql.Field
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.
3 2002/07/26 05:29:35 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.
4 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.ResultSet interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1ResultSet
...
...
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1ResultSetMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
View file @
f37c1c48
...
...
@@ -3,7 +3,7 @@ package org.postgresql.jdbc1;
import
java.sql.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.
2 2002/07/24 22:08:40 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.
3 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Statement interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Statement
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.net.ConnectException;
import
java.sql.*
;
import
org.postgresql.util.PSQLException
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.
1 2002/07/23 03:59:55 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
* methods. The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
...
...
@@ -55,34 +55,44 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
public
void
cancelQuery
()
throws
SQLException
{
org
.
postgresql
.
PG_Stream
cancelStream
=
null
;
try
{
try
{
cancelStream
=
new
org
.
postgresql
.
PG_Stream
(
PG_HOST
,
PG_PORT
);
}
catch
(
ConnectException
cex
)
{
}
catch
(
ConnectException
cex
)
{
// Added by Peter Mount <peter@retep.org.uk>
// ConnectException is thrown when the connection cannot be made.
// we trap this an return a more meaningful message for the end user
throw
new
PSQLException
(
"postgresql.con.refused"
);
}
catch
(
IOException
e
)
{
throw
new
PSQLException
(
"postgresql.con.failed"
,
e
);
}
catch
(
IOException
e
)
{
throw
new
PSQLException
(
"postgresql.con.failed"
,
e
);
}
// Now we need to construct and send a cancel packet
try
{
try
{
cancelStream
.
SendInteger
(
16
,
4
);
cancelStream
.
SendInteger
(
80877102
,
4
);
cancelStream
.
SendInteger
(
pid
,
4
);
cancelStream
.
SendInteger
(
ckey
,
4
);
cancelStream
.
flush
();
}
catch
(
IOException
e
)
{
throw
new
PSQLException
(
"postgresql.con.failed"
,
e
);
catch
(
IOException
e
)
{
throw
new
PSQLException
(
"postgresql.con.failed"
,
e
);
}
finally
{
try
{
if
(
cancelStream
!=
null
)
finally
{
try
{
if
(
cancelStream
!=
null
)
cancelStream
.
close
();
}
catch
(
IOException
e
)
{}
// Ignore
catch
(
IOException
e
)
{}
// Ignore
}
}
...
...
@@ -111,8 +121,10 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
//Because the get/setLogStream methods are deprecated in JDBC2
//we use the get/setLogWriter methods here for JDBC2 by overriding
//the base version of this method
protected
void
enableDriverManagerLogging
()
{
if
(
DriverManager
.
getLogWriter
()
==
null
)
{
protected
void
enableDriverManagerLogging
()
{
if
(
DriverManager
.
getLogWriter
()
==
null
)
{
DriverManager
.
setLogWriter
(
new
PrintWriter
(
System
.
out
));
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
View file @
f37c1c48
...
...
@@ -15,12 +15,13 @@ import org.postgresql.util.PGbytea;
import
org.postgresql.util.PSQLException
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.
6 2002/09/01 23:40:36 davec
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.
7 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1ResultSet which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2ResultSet
*/
public
abstract
class
AbstractJdbc2ResultSet
extends
org
.
postgresql
.
jdbc1
.
AbstractJdbc1ResultSet
{
public
abstract
class
AbstractJdbc2ResultSet
extends
org
.
postgresql
.
jdbc1
.
AbstractJdbc1ResultSet
{
//needed for updateable result set support
protected
boolean
updateable
=
false
;
...
...
@@ -39,16 +40,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
AbstractJdbc2ResultSet
(
org
.
postgresql
.
PGConnection
conn
,
Statement
statement
,
Field
[]
fields
,
Vector
tuples
,
String
status
,
int
updateCount
,
long
insertOID
,
boolean
binaryCursor
)
{
public
AbstractJdbc2ResultSet
(
org
.
postgresql
.
PGConnection
conn
,
Statement
statement
,
Field
[]
fields
,
Vector
tuples
,
String
status
,
int
updateCount
,
long
insertOID
,
boolean
binaryCursor
)
{
super
(
conn
,
statement
,
fields
,
tuples
,
status
,
updateCount
,
insertOID
,
binaryCursor
);
}
public
java
.
net
.
URL
getURL
(
int
columnIndex
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
int
columnIndex
)
throws
SQLException
{
return
null
;
}
public
java
.
net
.
URL
getURL
(
String
columnName
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
String
columnName
)
throws
SQLException
{
return
null
;
}
...
...
@@ -68,7 +72,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
* @return a Object holding the column value
* @exception SQLException if a database access error occurs
*/
public
Object
getObject
(
int
columnIndex
)
throws
SQLException
{
public
Object
getObject
(
int
columnIndex
)
throws
SQLException
{
Field
field
;
checkResultSet
(
columnIndex
);
...
...
@@ -80,12 +85,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
field
=
fields
[
columnIndex
-
1
];
// some fields can be null, mainly from those returned by MetaData methods
if
(
field
==
null
)
{
if
(
field
==
null
)
{
wasNullFlag
=
true
;
return
null
;
}
switch
(
field
.
getSQLType
())
{
switch
(
field
.
getSQLType
())
{
case
Types
.
BIT
:
return
getBoolean
(
columnIndex
)
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
...
...
@@ -131,17 +138,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
default
:
String
type
=
field
.
getPGType
();
// if the backend doesn't know the type then coerce to String
if
(
type
.
equals
(
"unknown"
))
{
if
(
type
.
equals
(
"unknown"
))
{
return
getString
(
columnIndex
);
}
else
{
else
{
return
connection
.
getObject
(
field
.
getPGType
(),
getString
(
columnIndex
));
}
}
}
public
boolean
absolute
(
int
index
)
throws
SQLException
{
public
boolean
absolute
(
int
index
)
throws
SQLException
{
// index is 1-based, but internally we use 0-based indices
int
internalIndex
;
...
...
@@ -152,21 +162,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
//if index<0, count from the end of the result set, but check
//to be sure that it is not beyond the first index
if
(
index
<
0
)
{
if
(
index
<
0
)
{
if
(
index
>=
-
rows_size
)
internalIndex
=
rows_size
+
index
;
else
{
else
{
beforeFirst
();
return
false
;
}
}
else
{
else
{
//must be the case that index>0,
//find the correct place, assuming that
//the index is not too large
if
(
index
<=
rows_size
)
internalIndex
=
index
-
1
;
else
{
else
{
afterLast
();
return
false
;
}
...
...
@@ -178,14 +192,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
void
afterLast
()
throws
SQLException
{
public
void
afterLast
()
throws
SQLException
{
final
int
rows_size
=
rows
.
size
();
if
(
rows_size
>
0
)
current_row
=
rows_size
;
}
public
void
beforeFirst
()
throws
SQLException
{
public
void
beforeFirst
()
throws
SQLException
{
if
(
rows
.
size
()
>
0
)
current_row
=
-
1
;
}
...
...
@@ -207,12 +223,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
java
.
sql
.
Array
getArray
(
String
colName
)
throws
SQLException
{
public
java
.
sql
.
Array
getArray
(
String
colName
)
throws
SQLException
{
return
getArray
(
findColumn
(
colName
));
}
public
java
.
sql
.
Array
getArray
(
int
i
)
throws
SQLException
{
public
java
.
sql
.
Array
getArray
(
int
i
)
throws
SQLException
{
wasNullFlag
=
(
this_row
[
i
-
1
]
==
null
);
if
(
wasNullFlag
)
return
null
;
...
...
@@ -223,17 +241,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
java
.
math
.
BigDecimal
getBigDecimal
(
int
columnIndex
)
throws
SQLException
{
public
java
.
math
.
BigDecimal
getBigDecimal
(
int
columnIndex
)
throws
SQLException
{
return
getBigDecimal
(
columnIndex
,
-
1
);
}
public
java
.
math
.
BigDecimal
getBigDecimal
(
String
columnName
)
throws
SQLException
{
public
java
.
math
.
BigDecimal
getBigDecimal
(
String
columnName
)
throws
SQLException
{
return
getBigDecimal
(
findColumn
(
columnName
));
}
public
Blob
getBlob
(
String
columnName
)
throws
SQLException
{
public
Blob
getBlob
(
String
columnName
)
throws
SQLException
{
return
getBlob
(
findColumn
(
columnName
));
}
...
...
@@ -241,18 +262,21 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
abstract
Blob
getBlob
(
int
i
)
throws
SQLException
;
public
java
.
io
.
Reader
getCharacterStream
(
String
columnName
)
throws
SQLException
{
public
java
.
io
.
Reader
getCharacterStream
(
String
columnName
)
throws
SQLException
{
return
getCharacterStream
(
findColumn
(
columnName
));
}
public
java
.
io
.
Reader
getCharacterStream
(
int
i
)
throws
SQLException
{
public
java
.
io
.
Reader
getCharacterStream
(
int
i
)
throws
SQLException
{
checkResultSet
(
i
);
wasNullFlag
=
(
this_row
[
i
-
1
]
==
null
);
if
(
wasNullFlag
)
return
null
;
if
(((
AbstractJdbc2Connection
)
connection
).
haveMinimumCompatibleVersion
(
"7.2"
))
{
if
(((
AbstractJdbc2Connection
)
connection
).
haveMinimumCompatibleVersion
(
"7.2"
))
{
//Version 7.2 supports AsciiStream for all the PG text types
//As the spec/javadoc for this method indicate this is to be used for
//large text values (i.e. LONGVARCHAR) PG doesn't have a separate
...
...
@@ -261,7 +285,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
//getString() since there is no current way to stream the value from the server
return
new
CharArrayReader
(
getString
(
i
).
toCharArray
());
}
else
{
else
{
// In 7.1 Handle as BLOBS so return the LargeObject input stream
Encoding
encoding
=
connection
.
getEncoding
();
InputStream
input
=
getBinaryStream
(
i
);
...
...
@@ -270,7 +295,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
Clob
getClob
(
String
columnName
)
throws
SQLException
{
public
Clob
getClob
(
String
columnName
)
throws
SQLException
{
return
getClob
(
findColumn
(
columnName
));
}
...
...
@@ -278,14 +304,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
abstract
Clob
getClob
(
int
i
)
throws
SQLException
;
public
int
getConcurrency
()
throws
SQLException
{
public
int
getConcurrency
()
throws
SQLException
{
if
(
statement
==
null
)
return
java
.
sql
.
ResultSet
.
CONCUR_READ_ONLY
;
return
statement
.
getResultSetConcurrency
();
}
public
java
.
sql
.
Date
getDate
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
java
.
sql
.
Date
getDate
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
// If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getDate()?
// for now...
...
...
@@ -293,7 +321,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
Time
getTime
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
Time
getTime
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
// If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getTime()?
// for now...
...
...
@@ -301,7 +330,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
Timestamp
getTimestamp
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
Timestamp
getTimestamp
(
int
i
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
// If I read the specs, this should use cal only if we don't
// store the timezone, and if we do, then act just like getDate()?
// for now...
...
...
@@ -309,28 +339,33 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
java
.
sql
.
Date
getDate
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
java
.
sql
.
Date
getDate
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
return
getDate
(
findColumn
(
c
),
cal
);
}
public
Time
getTime
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
Time
getTime
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
return
getTime
(
findColumn
(
c
),
cal
);
}
public
Timestamp
getTimestamp
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
public
Timestamp
getTimestamp
(
String
c
,
java
.
util
.
Calendar
cal
)
throws
SQLException
{
return
getTimestamp
(
findColumn
(
c
),
cal
);
}
public
int
getFetchDirection
()
throws
SQLException
{
public
int
getFetchDirection
()
throws
SQLException
{
//PostgreSQL normally sends rows first->last
return
java
.
sql
.
ResultSet
.
FETCH_FORWARD
;
}
public
int
getFetchSize
()
throws
SQLException
{
public
int
getFetchSize
()
throws
SQLException
{
// In this implementation we return the entire result set, so
// here return the number of rows we have. Sub-classes can return a proper
// value
...
...
@@ -338,7 +373,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
Object
getObject
(
String
columnName
,
java
.
util
.
Map
map
)
throws
SQLException
{
public
Object
getObject
(
String
columnName
,
java
.
util
.
Map
map
)
throws
SQLException
{
return
getObject
(
findColumn
(
columnName
),
map
);
}
...
...
@@ -348,23 +384,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
* an object based on that mapping. The class must implement the SQLData
* interface.
*/
public
Object
getObject
(
int
i
,
java
.
util
.
Map
map
)
throws
SQLException
{
public
Object
getObject
(
int
i
,
java
.
util
.
Map
map
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
public
Ref
getRef
(
String
columnName
)
throws
SQLException
{
public
Ref
getRef
(
String
columnName
)
throws
SQLException
{
return
getRef
(
findColumn
(
columnName
));
}
public
Ref
getRef
(
int
i
)
throws
SQLException
{
public
Ref
getRef
(
int
i
)
throws
SQLException
{
//The backend doesn't yet have SQL3 REF types
throw
new
PSQLException
(
"postgresql.psqlnotimp"
);
}
public
int
getRow
()
throws
SQLException
{
public
int
getRow
()
throws
SQLException
{
final
int
rows_size
=
rows
.
size
();
if
(
current_row
<
0
||
current_row
>=
rows_size
)
...
...
@@ -375,12 +415,14 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
// This one needs some thought, as not all ResultSets come from a statement
public
Statement
getStatement
()
throws
SQLException
{
public
Statement
getStatement
()
throws
SQLException
{
return
statement
;
}
public
int
getType
()
throws
SQLException
{
public
int
getType
()
throws
SQLException
{
// This implementation allows scrolling but is not able to
// see any changes. Sub-classes may overide this to return a more
// meaningful result.
...
...
@@ -388,29 +430,34 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
boolean
isAfterLast
()
throws
SQLException
{
public
boolean
isAfterLast
()
throws
SQLException
{
final
int
rows_size
=
rows
.
size
();
return
(
current_row
>=
rows_size
&&
rows_size
>
0
);
}
public
boolean
isBeforeFirst
()
throws
SQLException
{
public
boolean
isBeforeFirst
()
throws
SQLException
{
return
(
current_row
<
0
&&
rows
.
size
()
>
0
);
}
public
boolean
isFirst
()
throws
SQLException
{
public
boolean
isFirst
()
throws
SQLException
{
return
(
current_row
==
0
&&
rows
.
size
()
>=
0
);
}
public
boolean
isLast
()
throws
SQLException
{
public
boolean
isLast
()
throws
SQLException
{
final
int
rows_size
=
rows
.
size
();
return
(
current_row
==
rows_size
-
1
&&
rows_size
>
0
);
}
public
boolean
last
()
throws
SQLException
{
public
boolean
last
()
throws
SQLException
{
final
int
rows_size
=
rows
.
size
();
if
(
rows_size
<=
0
)
return
false
;
...
...
@@ -425,7 +472,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
boolean
previous
()
throws
SQLException
{
public
boolean
previous
()
throws
SQLException
{
if
(--
current_row
<
0
)
return
false
;
this_row
=
(
byte
[][])
rows
.
elementAt
(
current_row
);
...
...
@@ -434,24 +482,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
boolean
relative
(
int
rows
)
throws
SQLException
{
public
boolean
relative
(
int
rows
)
throws
SQLException
{
//have to add 1 since absolute expects a 1-based index
return
absolute
(
current_row
+
1
+
rows
);
}
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
public
void
setFetchDirection
(
int
direction
)
throws
SQLException
{
throw
new
PSQLException
(
"postgresql.psqlnotimp"
);
}
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
public
void
setFetchSize
(
int
rows
)
throws
SQLException
{
// Sub-classes should implement this as part of their cursor support
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
public
synchronized
void
cancelRowUpdates
()
throws
SQLException
public
synchronized
void
cancelRowUpdates
()
throws
SQLException
{
if
(
doingUpdates
)
{
...
...
@@ -462,36 +514,45 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
deleteRow
()
throws
SQLException
public
synchronized
void
deleteRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
onInsertRow
)
{
if
(
onInsertRow
)
{
throw
new
PSQLException
(
"postgresql.updateable.oninsertrow"
);
}
if
(
rows
.
size
()
==
0
)
{
if
(
rows
.
size
()
==
0
)
{
throw
new
PSQLException
(
"postgresql.updateable.emptydelete"
);
}
if
(
isBeforeFirst
())
{
if
(
isBeforeFirst
())
{
throw
new
PSQLException
(
"postgresql.updateable.beforestartdelete"
);
}
if
(
isAfterLast
())
{
if
(
isAfterLast
())
{
throw
new
PSQLException
(
"postgresql.updateable.afterlastdelete"
);
}
int
numKeys
=
primaryKeys
.
size
();
if
(
deleteStatement
==
null
)
{
if
(
deleteStatement
==
null
)
{
StringBuffer
deleteSQL
=
new
StringBuffer
(
"DELETE FROM "
).
append
(
tableName
).
append
(
" where "
);
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
deleteSQL
.
append
(
((
PrimaryKey
)
primaryKeys
.
get
(
i
)).
name
).
append
(
" = ? "
);
if
(
i
<
numKeys
-
1
)
{
if
(
i
<
numKeys
-
1
)
{
deleteSQL
.
append
(
" and "
);
}
}
...
...
@@ -500,7 +561,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
deleteStatement
.
clearParameters
();
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
deleteStatement
.
setObject
(
i
+
1
,
((
PrimaryKey
)
primaryKeys
.
get
(
i
)).
getValue
());
}
...
...
@@ -511,15 +573,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
insertRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
insertRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(!
onInsertRow
)
{
if
(!
onInsertRow
)
{
throw
new
PSQLException
(
"postgresql.updateable.notoninsertrow"
);
}
else
{
else
{
// loop through the keys in the insertTable and create the sql statement
// we have to create the sql every time since the user could insert different
...
...
@@ -531,15 +598,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
Enumeration
columnNames
=
updateValues
.
keys
();
int
numColumns
=
updateValues
.
size
();
for
(
int
i
=
0
;
columnNames
.
hasMoreElements
();
i
++
)
{
for
(
int
i
=
0
;
columnNames
.
hasMoreElements
();
i
++
)
{
String
columnName
=
(
String
)
columnNames
.
nextElement
();
insertSQL
.
append
(
columnName
);
if
(
i
<
numColumns
-
1
)
{
if
(
i
<
numColumns
-
1
)
{
insertSQL
.
append
(
", "
);
paramSQL
.
append
(
"?,"
);
}
else
{
else
{
paramSQL
.
append
(
"?)"
);
}
...
...
@@ -550,14 +620,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
Enumeration
keys
=
updateValues
.
keys
();
for
(
int
i
=
1
;
keys
.
hasMoreElements
();
i
++)
{
for
(
int
i
=
1
;
keys
.
hasMoreElements
();
i
++)
{
String
key
=
(
String
)
keys
.
nextElement
();
insertStatement
.
setObject
(
i
,
updateValues
.
get
(
key
)
);
}
insertStatement
.
executeUpdate
();
if
(
usingOID
)
{
if
(
usingOID
)
{
// we have to get the last inserted OID and put it in the resultset
long
insertedOID
=
((
AbstractJdbc2Statement
)
insertStatement
).
getLastOID
();
...
...
@@ -583,8 +655,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
moveToCurrentRow
()
throws
SQLException
{
if
(!
updateable
)
{
public
synchronized
void
moveToCurrentRow
()
throws
SQLException
{
if
(!
updateable
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -598,7 +673,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
moveToInsertRow
()
throws
SQLException
public
synchronized
void
moveToInsertRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
...
...
@@ -620,7 +696,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
private
synchronized
void
clearRowBuffer
()
throws
SQLException
private
synchronized
void
clearRowBuffer
()
throws
SQLException
{
// rowBuffer is the temporary storage for the row
rowBuffer
=
new
byte
[
fields
.
length
][];
...
...
@@ -631,19 +708,22 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
boolean
rowDeleted
()
throws
SQLException
{
public
boolean
rowDeleted
()
throws
SQLException
{
// only sub-classes implement CONCURuPDATEABLE
throw
Driver
.
notImplemented
();
}
public
boolean
rowInserted
()
throws
SQLException
{
public
boolean
rowInserted
()
throws
SQLException
{
// only sub-classes implement CONCURuPDATEABLE
throw
Driver
.
notImplemented
();
}
public
boolean
rowUpdated
()
throws
SQLException
{
public
boolean
rowUpdated
()
throws
SQLException
{
// only sub-classes implement CONCURuPDATEABLE
throw
Driver
.
notImplemented
();
}
...
...
@@ -652,21 +732,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
synchronized
void
updateAsciiStream
(
int
columnIndex
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
byte
[]
theData
=
null
;
try
{
try
{
x
.
read
(
theData
,
0
,
length
);
}
catch
(
NullPointerException
ex
)
{
catch
(
NullPointerException
ex
)
{
throw
new
PSQLException
(
"postgresql.updateable.inputstream"
);
}
catch
(
IOException
ie
)
{
catch
(
IOException
ie
)
{
throw
new
PSQLException
(
"postgresql.updateable.ioerror"
+
ie
);
}
...
...
@@ -679,9 +765,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
synchronized
void
updateBigDecimal
(
int
columnIndex
,
java
.
math
.
BigDecimal
x
)
throws
SQLException
{
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -694,22 +782,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
synchronized
void
updateBinaryStream
(
int
columnIndex
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
byte
[]
theData
=
null
;
try
{
try
{
x
.
read
(
theData
,
0
,
length
);
}
catch
(
NullPointerException
ex
)
{
catch
(
NullPointerException
ex
)
{
throw
new
PSQLException
(
"postgresql.updateable.inputstream"
);
}
catch
(
IOException
ie
)
{
catch
(
IOException
ie
)
{
throw
new
PSQLException
(
"postgresql.updateable.ioerror"
+
ie
);
}
...
...
@@ -720,13 +814,17 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateBoolean
(
int
columnIndex
,
boolean
x
)
throws
SQLException
{
public
synchronized
void
updateBoolean
(
int
columnIndex
,
boolean
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating boolean "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating boolean "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
new
Boolean
(
x
)
);
...
...
@@ -734,8 +832,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateByte
(
int
columnIndex
,
byte
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateByte
(
int
columnIndex
,
byte
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -744,9 +845,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateBytes
(
int
columnIndex
,
byte
[]
x
)
throws
SQLException
{
public
synchronized
void
updateBytes
(
int
columnIndex
,
byte
[]
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -759,22 +863,28 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
public
synchronized
void
updateCharacterStream
(
int
columnIndex
,
java
.
io
.
Reader
x
,
int
length
)
throws
SQLException
{
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
char
[]
theData
=
null
;
try
{
try
{
x
.
read
(
theData
,
0
,
length
);
}
catch
(
NullPointerException
ex
)
{
catch
(
NullPointerException
ex
)
{
throw
new
PSQLException
(
"postgresql.updateable.inputstream"
);
}
catch
(
IOException
ie
)
{
catch
(
IOException
ie
)
{
throw
new
PSQLException
(
"postgresql.updateable.ioerror"
+
ie
);
}
...
...
@@ -784,9 +894,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateDate
(
int
columnIndex
,
java
.
sql
.
Date
x
)
throws
SQLException
{
public
synchronized
void
updateDate
(
int
columnIndex
,
java
.
sql
.
Date
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -795,12 +908,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateDouble
(
int
columnIndex
,
double
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateDouble
(
int
columnIndex
,
double
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating double "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating double "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
new
Double
(
x
)
);
...
...
@@ -808,12 +925,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateFloat
(
int
columnIndex
,
float
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateFloat
(
int
columnIndex
,
float
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating float "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating float "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
doingUpdates
=
!
onInsertRow
;
...
...
@@ -822,12 +943,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateInt
(
int
columnIndex
,
int
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateInt
(
int
columnIndex
,
int
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating int "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating int "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
new
Integer
(
x
)
);
...
...
@@ -835,12 +960,16 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateLong
(
int
columnIndex
,
long
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateLong
(
int
columnIndex
,
long
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating long "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating long "
+
fields
[
columnIndex
-
1
].
getName
()
+
"="
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
new
Long
(
x
)
);
...
...
@@ -848,8 +977,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateNull
(
int
columnIndex
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateNull
(
int
columnIndex
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -860,20 +992,27 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateObject
(
int
columnIndex
,
Object
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateObject
(
int
columnIndex
,
Object
x
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating object "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating object "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
x
);
}
public
synchronized
void
updateObject
(
int
columnIndex
,
Object
x
,
int
scale
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateObject
(
int
columnIndex
,
Object
x
,
int
scale
)
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
...
...
@@ -882,21 +1021,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
void
refreshRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
void
refreshRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
try
{
try
{
StringBuffer
selectSQL
=
new
StringBuffer
(
"select "
);
final
int
numColumns
=
java
.
lang
.
reflect
.
Array
.
getLength
(
fields
);
for
(
int
i
=
0
;
i
<
numColumns
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numColumns
;
i
++
)
{
selectSQL
.
append
(
fields
[
i
].
getName
()
);
if
(
i
<
numColumns
-
1
)
{
if
(
i
<
numColumns
-
1
)
{
selectSQL
.
append
(
", "
);
}
...
...
@@ -906,65 +1050,80 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
int
numKeys
=
primaryKeys
.
size
();
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
PrimaryKey
primaryKey
=
((
PrimaryKey
)
primaryKeys
.
get
(
i
));
selectSQL
.
append
(
primaryKey
.
name
).
append
(
"= ?"
);
if
(
i
<
numKeys
-
1
)
{
if
(
i
<
numKeys
-
1
)
{
selectSQL
.
append
(
" and "
);
}
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"selecting "
+
selectSQL
.
toString
());
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"selecting "
+
selectSQL
.
toString
());
selectStatement
=
((
java
.
sql
.
Connection
)
connection
).
prepareStatement
(
selectSQL
.
toString
());
for
(
int
j
=
0
,
i
=
1
;
j
<
numKeys
;
j
++,
i
++)
{
for
(
int
j
=
0
,
i
=
1
;
j
<
numKeys
;
j
++,
i
++)
{
selectStatement
.
setObject
(
i
,
((
PrimaryKey
)
primaryKeys
.
get
(
j
)).
getValue
()
);
}
AbstractJdbc2ResultSet
rs
=
(
AbstractJdbc2ResultSet
)
selectStatement
.
executeQuery
();
if
(
rs
.
first
()
)
{
if
(
rs
.
first
()
)
{
rowBuffer
=
rs
.
rowBuffer
;
}
rows
.
setElementAt
(
rowBuffer
,
current_row
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"done updates"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"done updates"
);
rs
.
close
();
selectStatement
.
close
();
selectStatement
=
null
;
}
catch
(
Exception
e
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
e
.
getClass
().
getName
()
+
e
);
catch
(
Exception
e
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
e
.
getClass
().
getName
()
+
e
);
throw
new
SQLException
(
e
.
getMessage
()
);
}
}
public
synchronized
void
updateRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
public
synchronized
void
updateRow
()
throws
SQLException
{
if
(
!
isUpdateable
()
)
{
throw
new
PSQLException
(
"postgresql.updateable.notupdateable"
);
}
if
(
doingUpdates
)
{
if
(
doingUpdates
)
{
try
{
try
{
StringBuffer
updateSQL
=
new
StringBuffer
(
"UPDATE "
+
tableName
+
" SET "
);
int
numColumns
=
updateValues
.
size
();
Enumeration
columns
=
updateValues
.
keys
();
for
(
int
i
=
0
;
columns
.
hasMoreElements
();
i
++
)
{
for
(
int
i
=
0
;
columns
.
hasMoreElements
();
i
++
)
{
String
column
=
(
String
)
columns
.
nextElement
();
updateSQL
.
append
(
column
+
"= ?"
);
if
(
i
<
numColumns
-
1
)
{
if
(
i
<
numColumns
-
1
)
{
updateSQL
.
append
(
", "
);
}
...
...
@@ -974,25 +1133,30 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
int
numKeys
=
primaryKeys
.
size
();
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numKeys
;
i
++
)
{
PrimaryKey
primaryKey
=
((
PrimaryKey
)
primaryKeys
.
get
(
i
));
updateSQL
.
append
(
primaryKey
.
name
).
append
(
"= ?"
);
if
(
i
<
numKeys
-
1
)
{
if
(
i
<
numKeys
-
1
)
{
updateSQL
.
append
(
" and "
);
}
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating "
+
updateSQL
.
toString
());
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating "
+
updateSQL
.
toString
());
updateStatement
=
((
java
.
sql
.
Connection
)
connection
).
prepareStatement
(
updateSQL
.
toString
());
int
i
=
0
;
Iterator
iterator
=
updateValues
.
values
().
iterator
();
for
(;
iterator
.
hasNext
();
i
++)
{
for
(;
iterator
.
hasNext
();
i
++)
{
updateStatement
.
setObject
(
i
+
1
,
iterator
.
next
()
);
}
for
(
int
j
=
0
;
j
<
numKeys
;
j
++,
i
++)
{
for
(
int
j
=
0
;
j
<
numKeys
;
j
++,
i
++)
{
updateStatement
.
setObject
(
i
+
1
,
((
PrimaryKey
)
primaryKeys
.
get
(
j
)).
getValue
()
);
}
...
...
@@ -1003,16 +1167,20 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
updateRowBuffer
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"copying data"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"copying data"
);
System
.
arraycopy
(
rowBuffer
,
0
,
this_row
,
0
,
rowBuffer
.
length
);
rows
.
setElementAt
(
rowBuffer
,
current_row
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"done updates"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"done updates"
);
doingUpdates
=
false
;
}
catch
(
Exception
e
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
e
.
getClass
().
getName
()
+
e
);
catch
(
Exception
e
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
e
.
getClass
().
getName
()
+
e
);
throw
new
SQLException
(
e
.
getMessage
()
);
}
...
...
@@ -1021,8 +1189,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateShort
(
int
columnIndex
,
short
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update Short "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
public
synchronized
void
updateShort
(
int
columnIndex
,
short
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update Short "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
doingUpdates
=
!
onInsertRow
;
...
...
@@ -1031,8 +1202,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateString
(
int
columnIndex
,
String
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update String "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
public
synchronized
void
updateString
(
int
columnIndex
,
String
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update String "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
x
);
...
...
@@ -1040,8 +1214,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateTime
(
int
columnIndex
,
Time
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update Time "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
public
synchronized
void
updateTime
(
int
columnIndex
,
Time
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"in update Time "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
doingUpdates
=
!
onInsertRow
;
...
...
@@ -1050,8 +1227,11 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateTimestamp
(
int
columnIndex
,
Timestamp
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating Timestamp "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
public
synchronized
void
updateTimestamp
(
int
columnIndex
,
Timestamp
x
)
throws
SQLException
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"updating Timestamp "
+
fields
[
columnIndex
-
1
].
getName
()
+
" = "
+
x
);
doingUpdates
=
!
onInsertRow
;
updateValues
.
put
(
fields
[
columnIndex
-
1
].
getName
(),
x
);
...
...
@@ -1060,76 +1240,100 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
synchronized
void
updateNull
(
String
columnName
)
throws
SQLException
{
public
synchronized
void
updateNull
(
String
columnName
)
throws
SQLException
{
updateNull
(
findColumn
(
columnName
));
}
public
synchronized
void
updateBoolean
(
String
columnName
,
boolean
x
)
throws
SQLException
{
public
synchronized
void
updateBoolean
(
String
columnName
,
boolean
x
)
throws
SQLException
{
updateBoolean
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateByte
(
String
columnName
,
byte
x
)
throws
SQLException
{
public
synchronized
void
updateByte
(
String
columnName
,
byte
x
)
throws
SQLException
{
updateByte
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateShort
(
String
columnName
,
short
x
)
throws
SQLException
{
public
synchronized
void
updateShort
(
String
columnName
,
short
x
)
throws
SQLException
{
updateShort
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateInt
(
String
columnName
,
int
x
)
throws
SQLException
{
public
synchronized
void
updateInt
(
String
columnName
,
int
x
)
throws
SQLException
{
updateInt
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateLong
(
String
columnName
,
long
x
)
throws
SQLException
{
public
synchronized
void
updateLong
(
String
columnName
,
long
x
)
throws
SQLException
{
updateLong
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateFloat
(
String
columnName
,
float
x
)
throws
SQLException
{
public
synchronized
void
updateFloat
(
String
columnName
,
float
x
)
throws
SQLException
{
updateFloat
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateDouble
(
String
columnName
,
double
x
)
throws
SQLException
{
public
synchronized
void
updateDouble
(
String
columnName
,
double
x
)
throws
SQLException
{
updateDouble
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateBigDecimal
(
String
columnName
,
BigDecimal
x
)
throws
SQLException
{
throws
SQLException
{
updateBigDecimal
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateString
(
String
columnName
,
String
x
)
throws
SQLException
{
public
synchronized
void
updateString
(
String
columnName
,
String
x
)
throws
SQLException
{
updateString
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateBytes
(
String
columnName
,
byte
x
[])
throws
SQLException
{
public
synchronized
void
updateBytes
(
String
columnName
,
byte
x
[])
throws
SQLException
{
updateBytes
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateDate
(
String
columnName
,
java
.
sql
.
Date
x
)
throws
SQLException
{
throws
SQLException
{
updateDate
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateTime
(
String
columnName
,
java
.
sql
.
Time
x
)
throws
SQLException
{
throws
SQLException
{
updateTime
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateTimestamp
(
String
columnName
,
java
.
sql
.
Timestamp
x
)
throws
SQLException
{
throws
SQLException
{
updateTimestamp
(
findColumn
(
columnName
),
x
);
}
...
...
@@ -1138,7 +1342,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String
columnName
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
throws
SQLException
{
updateAsciiStream
(
findColumn
(
columnName
),
x
,
length
);
}
...
...
@@ -1147,7 +1352,8 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String
columnName
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
throws
SQLException
{
updateBinaryStream
(
findColumn
(
columnName
),
x
,
length
);
}
...
...
@@ -1156,28 +1362,35 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
String
columnName
,
java
.
io
.
Reader
reader
,
int
length
)
throws
SQLException
{
throws
SQLException
{
updateCharacterStream
(
findColumn
(
columnName
),
reader
,
length
);
}
public
synchronized
void
updateObject
(
String
columnName
,
Object
x
,
int
scale
)
throws
SQLException
{
throws
SQLException
{
updateObject
(
findColumn
(
columnName
),
x
);
}
public
synchronized
void
updateObject
(
String
columnName
,
Object
x
)
throws
SQLException
{
public
synchronized
void
updateObject
(
String
columnName
,
Object
x
)
throws
SQLException
{
updateObject
(
findColumn
(
columnName
),
x
);
}
private
int
_findColumn
(
String
columnName
)
{
private
int
_findColumn
(
String
columnName
)
{
int
i
;
final
int
flen
=
fields
.
length
;
for
(
i
=
0
;
i
<
flen
;
++
i
)
{
if
(
fields
[
i
].
getName
().
equalsIgnoreCase
(
columnName
))
{
for
(
i
=
0
;
i
<
flen
;
++
i
)
{
if
(
fields
[
i
].
getName
().
equalsIgnoreCase
(
columnName
))
{
return
(
i
+
1
);
}
}
...
...
@@ -1192,18 +1405,23 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
boolean
isUpdateable
()
throws
SQLException
{
if
(
updateable
)
return
true
;
if
(
updateable
)
return
true
;
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"checking if rs is updateable"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"checking if rs is updateable"
);
parseQuery
();
if
(
singleTable
==
false
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"not a single table"
);
if
(
singleTable
==
false
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"not a single table"
);
return
false
;
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getting primary keys"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"getting primary keys"
);
//
// Contains the primary key?
...
...
@@ -1222,22 +1440,26 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
// if we find the oid then just use it
if
(
oidIndex
>
0
)
{
if
(
oidIndex
>
0
)
{
i
++;
primaryKeys
.
add
(
new
PrimaryKey
(
oidIndex
,
"oid"
)
);
usingOID
=
true
;
}
else
{
else
{
// otherwise go and get the primary keys and create a hashtable of keys
java
.
sql
.
ResultSet
rs
=
((
java
.
sql
.
Connection
)
connection
).
getMetaData
().
getPrimaryKeys
(
""
,
""
,
tableName
);
for
(;
rs
.
next
();
i
++
)
{
for
(;
rs
.
next
();
i
++
)
{
String
columnName
=
rs
.
getString
(
4
);
// get the columnName
int
index
=
findColumn
(
columnName
);
if
(
index
>
0
)
{
if
(
index
>
0
)
{
primaryKeys
.
add
(
new
PrimaryKey
(
index
,
columnName
)
);
// get the primary key information
}
}
...
...
@@ -1247,21 +1469,25 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
numKeys
=
primaryKeys
.
size
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"no of keys="
+
i
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"no of keys="
+
i
);
if
(
i
<
1
)
{
if
(
i
<
1
)
{
throw
new
SQLException
(
"No Primary Keys"
);
}
updateable
=
primaryKeys
.
size
()
>
0
;
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"checking primary key "
+
updateable
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"checking primary key "
+
updateable
);
return
updateable
;
}
public
void
parseQuery
()
{
public
void
parseQuery
()
{
String
[]
l_sqlFragments
=
((
AbstractJdbc2Statement
)
statement
).
getSqlFragments
();
String
l_sql
=
l_sqlFragments
[
0
];
StringTokenizer
st
=
new
StringTokenizer
(
l_sql
,
" \r\t"
);
...
...
@@ -1270,15 +1496,19 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
singleTable
=
true
;
while
(
!
tableFound
&&
!
tablesChecked
&&
st
.
hasMoreTokens
()
)
{
while
(
!
tableFound
&&
!
tablesChecked
&&
st
.
hasMoreTokens
()
)
{
name
=
st
.
nextToken
();
if
(
!
tableFound
)
{
if
(
name
.
toLowerCase
().
equals
(
"from"
))
{
if
(
!
tableFound
)
{
if
(
name
.
toLowerCase
().
equals
(
"from"
))
{
tableName
=
st
.
nextToken
();
tableFound
=
true
;
}
}
else
{
else
{
tablesChecked
=
true
;
// if the very next token is , then there are multiple tables
singleTable
=
!
name
.
equalsIgnoreCase
(
","
);
...
...
@@ -1287,15 +1517,18 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
private
void
updateRowBuffer
()
throws
SQLException
{
private
void
updateRowBuffer
()
throws
SQLException
{
Enumeration
columns
=
updateValues
.
keys
();
while
(
columns
.
hasMoreElements
()
)
{
while
(
columns
.
hasMoreElements
()
)
{
String
columnName
=
(
String
)
columns
.
nextElement
();
int
columnIndex
=
_findColumn
(
columnName
)
-
1
;
switch
(
connection
.
getSQLType
(
fields
[
columnIndex
].
getPGType
()
)
)
{
switch
(
connection
.
getSQLType
(
fields
[
columnIndex
].
getPGType
()
)
)
{
case
Types
.
DECIMAL
:
case
Types
.
BIGINT
:
...
...
@@ -1313,10 +1546,12 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
case
Types
.
REAL
:
case
Types
.
TINYINT
:
try
{
try
{
rowBuffer
[
columnIndex
]
=
String
.
valueOf
(
updateValues
.
get
(
columnName
)
).
getBytes
(
connection
.
getEncoding
().
name
()
);
}
catch
(
UnsupportedEncodingException
ex
)
{
catch
(
UnsupportedEncodingException
ex
)
{
throw
new
SQLException
(
"Unsupported Encoding "
+
connection
.
getEncoding
().
name
());
}
...
...
@@ -1331,20 +1566,24 @@ public abstract class AbstractJdbc2ResultSet extends org.postgresql.jdbc1.Abstra
}
public
void
setStatement
(
Statement
statement
)
{
public
void
setStatement
(
Statement
statement
)
{
this
.
statement
=
statement
;
}
private
class
PrimaryKey
{
private
class
PrimaryKey
{
int
index
;
// where in the result set is this primaryKey
String
name
;
// what is the columnName of this primary Key
PrimaryKey
(
int
index
,
String
name
)
{
PrimaryKey
(
int
index
,
String
name
)
{
this
.
index
=
index
;
this
.
name
=
name
;
}
Object
getValue
()
throws
SQLException
{
Object
getValue
()
throws
SQLException
{
return
getObject
(
index
);
}
};
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
View file @
f37c1c48
...
...
@@ -513,40 +513,40 @@ public abstract class AbstractJdbc2ResultSetMetaData extends org.postgresql.jdbc
switch
(
sql_type
)
{
case
Types
.
BIT
:
return
(
"java.lang.Boolean"
);
return
(
"java.lang.Boolean"
);
case
Types
.
SMALLINT
:
return
(
"java.lang.Short"
);
return
(
"java.lang.Short"
);
case
Types
.
INTEGER
:
return
(
"java.lang.Integer"
);
return
(
"java.lang.Integer"
);
case
Types
.
BIGINT
:
return
(
"java.lang.Long"
);
return
(
"java.lang.Long"
);
case
Types
.
NUMERIC
:
return
(
"java.math.BigDecimal"
);
return
(
"java.math.BigDecimal"
);
case
Types
.
REAL
:
return
(
"java.lang.Float"
);
return
(
"java.lang.Float"
);
case
Types
.
DOUBLE
:
return
(
"java.lang.Double"
);
return
(
"java.lang.Double"
);
case
Types
.
CHAR
:
case
Types
.
VARCHAR
:
return
(
"java.lang.String"
);
return
(
"java.lang.String"
);
case
Types
.
DATE
:
return
(
"java.sql.Date"
);
return
(
"java.sql.Date"
);
case
Types
.
TIME
:
return
(
"java.sql.Time"
);
return
(
"java.sql.Time"
);
case
Types
.
TIMESTAMP
:
return
(
"java.sql.Timestamp"
);
return
(
"java.sql.Timestamp"
);
case
Types
.
BINARY
:
case
Types
.
VARBINARY
:
return
(
"[B"
);
return
(
"[B"
);
case
Types
.
ARRAY
:
return
(
"java.sql.Array"
);
return
(
"java.sql.Array"
);
default
:
String
type
=
field
.
getPGType
();
if
(
"unknown"
.
equals
(
type
))
{
return
(
"java.lang.String"
);
return
(
"java.lang.String"
);
}
return
(
"java.lang.Object"
);
return
(
"java.lang.Object"
);
}
}
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java
View file @
f37c1c48
...
...
@@ -8,7 +8,7 @@ import java.util.Vector;
import
org.postgresql.largeobject.*
;
import
org.postgresql.util.PSQLException
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.
5 2002/09/02 03:07:36 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Statement.java,v 1.
6 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc2 specification. This class extends
* org.postgresql.jdbc1.AbstractJdbc1Statement which provides the jdbc1
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Statement
...
...
@@ -183,12 +183,12 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
// is buffered internally anyhow, so there would be no performance
// boost gained, if anything it would be worse!
int
bytesRemaining
=
(
int
)
x
.
length
();
int
numRead
=
l_inStream
.
read
(
buf
,
0
,
Math
.
min
(
buf
.
length
,
bytesRemaining
));
int
numRead
=
l_inStream
.
read
(
buf
,
0
,
Math
.
min
(
buf
.
length
,
bytesRemaining
));
while
(
numRead
!=
-
1
&&
bytesRemaining
>
0
)
{
bytesRemaining
-=
numRead
;
los
.
write
(
buf
,
0
,
numRead
);
numRead
=
l_inStream
.
read
(
buf
,
0
,
Math
.
min
(
buf
.
length
,
bytesRemaining
));
los
.
write
(
buf
,
0
,
numRead
);
numRead
=
l_inStream
.
read
(
buf
,
0
,
Math
.
min
(
buf
.
length
,
bytesRemaining
));
}
los
.
close
();
}
...
...
@@ -385,7 +385,8 @@ public abstract class AbstractJdbc2Statement extends org.postgresql.jdbc1.Abstra
//This is needed by AbstractJdbc2ResultSet to determine if the query is updateable or not
protected
String
[]
getSqlFragments
()
{
protected
String
[]
getSqlFragments
()
{
return
m_sqlFragments
;
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/Array.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Connection.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.util.Vector;
import
java.util.Hashtable
;
import
org.postgresql.Field
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.
4 2002/07/26 05:29:35 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Connection.java,v 1.
5 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Connection interface for JDBC2.
* However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2Connection or one of it's parents
...
...
@@ -33,7 +33,7 @@ public class Jdbc2Connection extends org.postgresql.jdbc2.AbstractJdbc2Connectio
public
java
.
sql
.
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
Jdbc2CallableStatement
s
=
new
org
.
postgresql
.
jdbc2
.
Jdbc2CallableStatement
(
this
,
sql
);
Jdbc2CallableStatement
s
=
new
org
.
postgresql
.
jdbc2
.
Jdbc2CallableStatement
(
this
,
sql
);
s
.
setResultSetType
(
resultSetType
);
s
.
setResultSetConcurrency
(
resultSetConcurrency
);
return
s
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import java.sql.*;
import
java.util.Vector
;
import
org.postgresql.Field
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.
4 2002/08/14 20:35:39 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.
5 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.ResultSet interface for JDBC2.
* However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
...
...
@@ -23,11 +23,13 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
return
new
Jdbc2ResultSetMetaData
(
rows
,
fields
);
}
public
java
.
sql
.
Clob
getClob
(
int
i
)
throws
SQLException
{
public
java
.
sql
.
Clob
getClob
(
int
i
)
throws
SQLException
{
return
new
org
.
postgresql
.
jdbc2
.
Jdbc2Clob
(
connection
,
getInt
(
i
));
}
public
java
.
sql
.
Blob
getBlob
(
int
i
)
throws
SQLException
{
public
java
.
sql
.
Blob
getBlob
(
int
i
)
throws
SQLException
{
return
new
org
.
postgresql
.
jdbc2
.
Jdbc2Blob
(
connection
,
getInt
(
i
));
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2ResultSetMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
View file @
f37c1c48
...
...
@@ -3,7 +3,7 @@ package org.postgresql.jdbc2;
import
java.sql.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.
2 2002/07/24 22:08:43 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.
3 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Statement interface for JDBC2.
* However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2Statement or one of it's parents
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/BaseDataSource.java
View file @
f37c1c48
...
...
@@ -8,16 +8,20 @@ import java.sql.*;
* Base class for data sources and related classes.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
abstract
class
BaseDataSource
implements
Referenceable
{
public
abstract
class
BaseDataSource
implements
Referenceable
{
// Load the normal driver, since we'll use it to actually connect to the
// database. That way we don't have to maintain the connecting code in
// multiple places.
static
{
try
{
try
{
Class
.
forName
(
"org.postgresql.Driver"
);
}
catch
(
ClassNotFoundException
e
)
{
}
catch
(
ClassNotFoundException
e
)
{
System
.
err
.
println
(
"PostgreSQL DataSource unable to load PostgreSQL JDBC Driver"
);
}
}
...
...
@@ -42,7 +46,8 @@ public abstract class BaseDataSource implements Referenceable {
* @throws SQLException
* Occurs when the database connection cannot be established.
*/
public
Connection
getConnection
()
throws
SQLException
{
public
Connection
getConnection
()
throws
SQLException
{
return
getConnection
(
user
,
password
);
}
...
...
@@ -56,15 +61,21 @@ public abstract class BaseDataSource implements Referenceable {
* @throws SQLException
* Occurs when the database connection cannot be established.
*/
public
Connection
getConnection
(
String
user
,
String
password
)
throws
SQLException
{
try
{
public
Connection
getConnection
(
String
user
,
String
password
)
throws
SQLException
{
try
{
Connection
con
=
DriverManager
.
getConnection
(
getUrl
(),
user
,
password
);
if
(
logger
!=
null
)
{
if
(
logger
!=
null
)
{
logger
.
println
(
"Created a non-pooled connection for "
+
user
+
" at "
+
getUrl
());
}
return
con
;
}
catch
(
SQLException
e
)
{
if
(
logger
!=
null
)
{
}
catch
(
SQLException
e
)
{
if
(
logger
!=
null
)
{
logger
.
println
(
"Failed to create a non-pooled connection for "
+
user
+
" at "
+
getUrl
()
+
": "
+
e
);
}
throw
e
;
...
...
@@ -75,7 +86,8 @@ public abstract class BaseDataSource implements Referenceable {
* This DataSource does not support a configurable login timeout.
* @return 0
*/
public
int
getLoginTimeout
()
throws
SQLException
{
public
int
getLoginTimeout
()
throws
SQLException
{
return
0
;
}
...
...
@@ -83,27 +95,30 @@ public abstract class BaseDataSource implements Referenceable {
* This DataSource does not support a configurable login timeout. Any value
* provided here will be ignored.
*/
public
void
setLoginTimeout
(
int
i
)
throws
SQLException
{
}
public
void
setLoginTimeout
(
int
i
)
throws
SQLException
{
}
/**
* Gets the log writer used to log connections opened.
*/
public
PrintWriter
getLogWriter
()
throws
SQLException
{
public
PrintWriter
getLogWriter
()
throws
SQLException
{
return
logger
;
}
/**
* The DataSource will note every connection opened to the provided log writer.
*/
public
void
setLogWriter
(
PrintWriter
printWriter
)
throws
SQLException
{
public
void
setLogWriter
(
PrintWriter
printWriter
)
throws
SQLException
{
logger
=
printWriter
;
}
/**
* Gets the name of the host the PostgreSQL database is running on.
*/
public
String
getServerName
()
{
public
String
getServerName
()
{
return
serverName
;
}
...
...
@@ -112,10 +127,14 @@ public abstract class BaseDataSource implements Referenceable {
* is changed, it will only affect future calls to getConnection. The default
* value is <tt>localhost</tt>.
*/
public
void
setServerName
(
String
serverName
)
{
if
(
serverName
==
null
||
serverName
.
equals
(
""
))
{
public
void
setServerName
(
String
serverName
)
{
if
(
serverName
==
null
||
serverName
.
equals
(
""
))
{
this
.
serverName
=
"localhost"
;
}
else
{
}
else
{
this
.
serverName
=
serverName
;
}
}
...
...
@@ -124,7 +143,8 @@ public abstract class BaseDataSource implements Referenceable {
* Gets the name of the PostgreSQL database, running on the server identified
* by the serverName property.
*/
public
String
getDatabaseName
()
{
public
String
getDatabaseName
()
{
return
databaseName
;
}
...
...
@@ -133,7 +153,8 @@ public abstract class BaseDataSource implements Referenceable {
* by the serverName property. If this is changed, it will only affect
* future calls to getConnection.
*/
public
void
setDatabaseName
(
String
databaseName
)
{
public
void
setDatabaseName
(
String
databaseName
)
{
this
.
databaseName
=
databaseName
;
}
...
...
@@ -147,7 +168,8 @@ public abstract class BaseDataSource implements Referenceable {
* Gets the user to connect as by default. If this is not specified, you must
* use the getConnection method which takes a user and password as parameters.
*/
public
String
getUser
()
{
public
String
getUser
()
{
return
user
;
}
...
...
@@ -156,7 +178,8 @@ public abstract class BaseDataSource implements Referenceable {
* use the getConnection method which takes a user and password as parameters.
* If this is changed, it will only affect future calls to getConnection.
*/
public
void
setUser
(
String
user
)
{
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
...
...
@@ -165,7 +188,8 @@ public abstract class BaseDataSource implements Referenceable {
* password is needed to log in, you must use the getConnection method which takes
* a user and password as parameters.
*/
public
String
getPassword
()
{
public
String
getPassword
()
{
return
password
;
}
...
...
@@ -175,7 +199,8 @@ public abstract class BaseDataSource implements Referenceable {
* a user and password as parameters. If this is changed, it will only affect
* future calls to getConnection.
*/
public
void
setPassword
(
String
password
)
{
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
...
...
@@ -185,7 +210,8 @@ public abstract class BaseDataSource implements Referenceable {
*
* @return The port, or 0 if the default port will be used.
*/
public
int
getPortNumber
()
{
public
int
getPortNumber
()
{
return
portNumber
;
}
...
...
@@ -194,28 +220,34 @@ public abstract class BaseDataSource implements Referenceable {
* connections. Be sure the -i flag is passed to postmaster when PostgreSQL
* is started. If this is not set, or set to 0, the default port will be used.
*/
public
void
setPortNumber
(
int
portNumber
)
{
public
void
setPortNumber
(
int
portNumber
)
{
this
.
portNumber
=
portNumber
;
}
/**
* Generates a DriverManager URL from the other properties supplied.
*/
private
String
getUrl
()
{
return
"jdbc:postgresql://"
+
serverName
+(
portNumber
==
0
?
""
:
":"
+
portNumber
)+
"/"
+
databaseName
;
private
String
getUrl
()
{
return
"jdbc:postgresql://"
+
serverName
+
(
portNumber
==
0
?
""
:
":"
+
portNumber
)
+
"/"
+
databaseName
;
}
public
Reference
getReference
()
throws
NamingException
{
public
Reference
getReference
()
throws
NamingException
{
Reference
ref
=
new
Reference
(
getClass
().
getName
(),
PGObjectFactory
.
class
.
getName
(),
null
);
ref
.
add
(
new
StringRefAddr
(
"serverName"
,
serverName
));
if
(
portNumber
!=
0
)
{
if
(
portNumber
!=
0
)
{
ref
.
add
(
new
StringRefAddr
(
"portNumber"
,
Integer
.
toString
(
portNumber
)));
}
ref
.
add
(
new
StringRefAddr
(
"databaseName"
,
databaseName
));
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
ref
.
add
(
new
StringRefAddr
(
"user"
,
user
));
}
if
(
password
!=
null
)
{
if
(
password
!=
null
)
{
ref
.
add
(
new
StringRefAddr
(
"password"
,
password
));
}
return
ref
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/ConnectionPool.java
View file @
f37c1c48
...
...
@@ -21,16 +21,18 @@ import java.io.Serializable;
* <p>This implementation supports JDK 1.3 and higher.</p>
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
ConnectionPool
extends
BaseDataSource
implements
Serializable
,
ConnectionPoolDataSource
{
public
class
ConnectionPool
extends
BaseDataSource
implements
Serializable
,
ConnectionPoolDataSource
{
private
boolean
defaultAutoCommit
=
false
;
/**
* Gets a description of this DataSource.
*/
public
String
getDescription
()
{
return
"ConnectionPoolDataSource from "
+
org
.
postgresql
.
Driver
.
getVersion
();
public
String
getDescription
()
{
return
"ConnectionPoolDataSource from "
+
org
.
postgresql
.
Driver
.
getVersion
();
}
/**
...
...
@@ -40,7 +42,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* @throws java.sql.SQLException
* Occurs when the physical database connection cannot be established.
*/
public
PooledConnection
getPooledConnection
()
throws
SQLException
{
public
PooledConnection
getPooledConnection
()
throws
SQLException
{
return
new
PooledConnectionImpl
(
getConnection
(),
defaultAutoCommit
);
}
...
...
@@ -51,7 +54,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* @throws java.sql.SQLException
* Occurs when the physical database connection cannot be established.
*/
public
PooledConnection
getPooledConnection
(
String
user
,
String
password
)
throws
SQLException
{
public
PooledConnection
getPooledConnection
(
String
user
,
String
password
)
throws
SQLException
{
return
new
PooledConnectionImpl
(
getConnection
(
user
,
password
),
defaultAutoCommit
);
}
...
...
@@ -60,7 +64,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* turned on by default. The default value is <tt>false</tt>, so that
* autoCommit will be turned off by default.
*/
public
boolean
isDefaultAutoCommit
()
{
public
boolean
isDefaultAutoCommit
()
{
return
defaultAutoCommit
;
}
...
...
@@ -69,7 +74,8 @@ public class ConnectionPool extends BaseDataSource implements Serializable, Conn
* turned on by default. The default value is <tt>false</tt>, so that
* autoCommit will be turned off by default.
*/
public
void
setDefaultAutoCommit
(
boolean
defaultAutoCommit
)
{
public
void
setDefaultAutoCommit
(
boolean
defaultAutoCommit
)
{
this
.
defaultAutoCommit
=
defaultAutoCommit
;
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java
View file @
f37c1c48
...
...
@@ -13,32 +13,43 @@ import java.util.Hashtable;
* consistent.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
PGObjectFactory
implements
ObjectFactory
{
public
class
PGObjectFactory
implements
ObjectFactory
{
/**
* Dereferences a PostgreSQL DataSource. Other types of references are
* ignored.
*/
public
Object
getObjectInstance
(
Object
obj
,
Name
name
,
Context
nameCtx
,
Hashtable
environment
)
throws
Exception
{
Hashtable
environment
)
throws
Exception
{
Reference
ref
=
(
Reference
)
obj
;
if
(
ref
.
getClassName
().
equals
(
SimpleDataSource
.
class
.
getName
()))
{
if
(
ref
.
getClassName
().
equals
(
SimpleDataSource
.
class
.
getName
()))
{
return
loadSimpleDataSource
(
ref
);
}
else
if
(
ref
.
getClassName
().
equals
(
ConnectionPool
.
class
.
getName
()))
{
}
else
if
(
ref
.
getClassName
().
equals
(
ConnectionPool
.
class
.
getName
()))
{
return
loadConnectionPool
(
ref
);
}
else
if
(
ref
.
getClassName
().
equals
(
PoolingDataSource
.
class
.
getName
()))
{
}
else
if
(
ref
.
getClassName
().
equals
(
PoolingDataSource
.
class
.
getName
()))
{
return
loadPoolingDataSource
(
ref
);
}
else
{
}
else
{
return
null
;
}
}
private
Object
loadPoolingDataSource
(
Reference
ref
)
{
private
Object
loadPoolingDataSource
(
Reference
ref
)
{
// If DataSource exists, return it
String
name
=
getProperty
(
ref
,
"dataSourceName"
);
PoolingDataSource
pds
=
PoolingDataSource
.
getDataSource
(
name
);
if
(
pds
!=
null
)
{
if
(
pds
!=
null
)
{
return
pds
;
}
// Otherwise, create a new one
...
...
@@ -46,31 +57,37 @@ public class PGObjectFactory implements ObjectFactory {
pds
.
setDataSourceName
(
name
);
loadBaseDataSource
(
pds
,
ref
);
String
min
=
getProperty
(
ref
,
"initialConnections"
);
if
(
min
!=
null
)
{
if
(
min
!=
null
)
{
pds
.
setInitialConnections
(
Integer
.
parseInt
(
min
));
}
String
max
=
getProperty
(
ref
,
"maxConnections"
);
if
(
max
!=
null
)
{
if
(
max
!=
null
)
{
pds
.
setMaxConnections
(
Integer
.
parseInt
(
max
));
}
return
pds
;
}
private
Object
loadSimpleDataSource
(
Reference
ref
)
{
private
Object
loadSimpleDataSource
(
Reference
ref
)
{
SimpleDataSource
ds
=
new
SimpleDataSource
();
return
loadBaseDataSource
(
ds
,
ref
);
}
private
Object
loadConnectionPool
(
Reference
ref
)
{
private
Object
loadConnectionPool
(
Reference
ref
)
{
ConnectionPool
cp
=
new
ConnectionPool
();
return
loadBaseDataSource
(
cp
,
ref
);
}
private
Object
loadBaseDataSource
(
BaseDataSource
ds
,
Reference
ref
)
{
private
Object
loadBaseDataSource
(
BaseDataSource
ds
,
Reference
ref
)
{
ds
.
setDatabaseName
(
getProperty
(
ref
,
"databaseName"
));
ds
.
setPassword
(
getProperty
(
ref
,
"password"
));
String
port
=
getProperty
(
ref
,
"portNumber"
);
if
(
port
!=
null
)
{
if
(
port
!=
null
)
{
ds
.
setPortNumber
(
Integer
.
parseInt
(
port
));
}
ds
.
setServerName
(
getProperty
(
ref
,
"serverName"
));
...
...
@@ -78,9 +95,11 @@ public class PGObjectFactory implements ObjectFactory {
return
ds
;
}
private
String
getProperty
(
Reference
ref
,
String
s
)
{
private
String
getProperty
(
Reference
ref
,
String
s
)
{
RefAddr
addr
=
ref
.
get
(
s
);
if
(
addr
==
null
)
{
if
(
addr
==
null
)
{
return
null
;
}
return
(
String
)
addr
.
getContent
();
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java
View file @
f37c1c48
...
...
@@ -13,9 +13,10 @@ import java.lang.reflect.*;
* @see ConnectionPool
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
PooledConnectionImpl
implements
PooledConnection
{
public
class
PooledConnectionImpl
implements
PooledConnection
{
private
List
listeners
=
new
LinkedList
();
private
Connection
con
;
private
ConnectionHandler
last
;
...
...
@@ -25,7 +26,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Creates a new PooledConnection representing the specified physical
* connection.
*/
PooledConnectionImpl
(
Connection
con
,
boolean
autoCommit
)
{
PooledConnectionImpl
(
Connection
con
,
boolean
autoCommit
)
{
this
.
con
=
con
;
this
.
autoCommit
=
autoCommit
;
}
...
...
@@ -34,7 +36,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Adds a listener for close or fatal error events on the connection
* handed out to a client.
*/
public
void
addConnectionEventListener
(
ConnectionEventListener
connectionEventListener
)
{
public
void
addConnectionEventListener
(
ConnectionEventListener
connectionEventListener
)
{
listeners
.
add
(
connectionEventListener
);
}
...
...
@@ -42,7 +45,8 @@ public class PooledConnectionImpl implements PooledConnection {
* Removes a listener for close or fatal error events on the connection
* handed out to a client.
*/
public
void
removeConnectionEventListener
(
ConnectionEventListener
connectionEventListener
)
{
public
void
removeConnectionEventListener
(
ConnectionEventListener
connectionEventListener
)
{
listeners
.
remove
(
connectionEventListener
);
}
...
...
@@ -51,16 +55,27 @@ public class PooledConnectionImpl implements PooledConnection {
* PooledConnection. If any client has a connection based on
* this PooledConnection, it is forcibly closed as well.
*/
public
void
close
()
throws
SQLException
{
if
(
last
!=
null
)
{
public
void
close
()
throws
SQLException
{
if
(
last
!=
null
)
{
last
.
close
();
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();}
catch
(
SQLException
e
)
{}
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();
}
catch
(
SQLException
e
)
{}
}
try
{
}
try
{
con
.
close
();
}
finally
{
}
finally
{
con
=
null
;
}
}
...
...
@@ -76,15 +91,24 @@ public class PooledConnectionImpl implements PooledConnection {
* there is a previous handle active when this is called, the previous
* one is forcibly closed and its work rolled back.</p>
*/
public
Connection
getConnection
()
throws
SQLException
{
if
(
con
==
null
)
{
public
Connection
getConnection
()
throws
SQLException
{
if
(
con
==
null
)
{
throw
new
SQLException
(
"This PooledConnection has already been closed!"
);
}
// Only one connection can be open at a time from this PooledConnection. See JDBC 2.0 Optional Package spec section 6.2.3
if
(
last
!=
null
)
{
if
(
last
!=
null
)
{
last
.
close
();
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();}
catch
(
SQLException
e
)
{}
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();
}
catch
(
SQLException
e
)
{}
}
con
.
clearWarnings
();
}
...
...
@@ -97,13 +121,16 @@ public class PooledConnectionImpl implements PooledConnection {
/**
* Used to fire a connection event to all listeners.
*/
void
fireConnectionClosed
()
{
void
fireConnectionClosed
()
{
ConnectionEvent
evt
=
null
;
// Copy the listener list so the listener can remove itself during this method call
ConnectionEventListener
[]
local
=
(
ConnectionEventListener
[])
listeners
.
toArray
(
new
ConnectionEventListener
[
listeners
.
size
()]);
for
(
int
i
=
0
;
i
<
local
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
local
.
length
;
i
++)
{
ConnectionEventListener
listener
=
local
[
i
];
if
(
evt
==
null
)
{
if
(
evt
==
null
)
{
evt
=
new
ConnectionEvent
(
this
);
}
listener
.
connectionClosed
(
evt
);
...
...
@@ -113,13 +140,16 @@ public class PooledConnectionImpl implements PooledConnection {
/**
* Used to fire a connection event to all listeners.
*/
void
fireConnectionFatalError
(
SQLException
e
)
{
void
fireConnectionFatalError
(
SQLException
e
)
{
ConnectionEvent
evt
=
null
;
// Copy the listener list so the listener can remove itself during this method call
ConnectionEventListener
[]
local
=
(
ConnectionEventListener
[])
listeners
.
toArray
(
new
ConnectionEventListener
[
listeners
.
size
()]);
for
(
int
i
=
0
;
i
<
local
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
local
.
length
;
i
++)
{
ConnectionEventListener
listener
=
local
[
i
];
if
(
evt
==
null
)
{
if
(
evt
==
null
)
{
evt
=
new
ConnectionEvent
(
this
,
e
);
}
listener
.
connectionErrorOccurred
(
evt
);
...
...
@@ -133,63 +163,90 @@ public class PooledConnectionImpl implements PooledConnection {
* requires JDK 1.3 or higher, though JDK 1.2 could be supported with a
* 3rd-party proxy package.
*/
private
class
ConnectionHandler
implements
InvocationHandler
{
private
class
ConnectionHandler
implements
InvocationHandler
{
private
Connection
con
;
private
boolean
automatic
=
false
;
public
ConnectionHandler
(
Connection
con
)
{
public
ConnectionHandler
(
Connection
con
)
{
this
.
con
=
con
;
}
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
throws
Throwable
{
// From Object
if
(
method
.
getDeclaringClass
().
getName
().
equals
(
"java.lang.Object"
))
{
if
(
method
.
getName
().
equals
(
"toString"
))
{
return
"Pooled connection wrapping physical connection "
+
con
;
}
if
(
method
.
getName
().
equals
(
"hashCode"
))
{
if
(
method
.
getDeclaringClass
().
getName
().
equals
(
"java.lang.Object"
))
{
if
(
method
.
getName
().
equals
(
"toString"
))
{
return
"Pooled connection wrapping physical connection "
+
con
;
}
if
(
method
.
getName
().
equals
(
"hashCode"
))
{
return
new
Integer
(
con
.
hashCode
());
}
if
(
method
.
getName
().
equals
(
"equals"
))
{
if
(
args
[
0
]
==
null
)
{
if
(
method
.
getName
().
equals
(
"equals"
))
{
if
(
args
[
0
]
==
null
)
{
return
Boolean
.
FALSE
;
}
try
{
try
{
return
Proxy
.
isProxyClass
(
args
[
0
].
getClass
())
&&
((
ConnectionHandler
)
Proxy
.
getInvocationHandler
(
args
[
0
])).
con
==
con
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
}
catch
(
ClassCastException
e
)
{
}
catch
(
ClassCastException
e
)
{
return
Boolean
.
FALSE
;
}
}
return
method
.
invoke
(
con
,
args
);
}
// All the rest is from the Connection interface
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
if
(
method
.
getName
().
equals
(
"isClosed"
))
{
return
con
==
null
?
Boolean
.
TRUE
:
Boolean
.
FALSE
;
}
if
(
con
==
null
)
{
if
(
con
==
null
)
{
throw
new
SQLException
(
automatic
?
"Connection has been closed automatically because a new connection was opened for the same PooledConnection or the PooledConnection has been closed"
:
"Connection has been closed"
);
}
if
(
method
.
getName
().
equals
(
"close"
))
{
if
(
method
.
getName
().
equals
(
"close"
))
{
SQLException
ex
=
null
;
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();}
catch
(
SQLException
e
)
{
ex
=
e
;}
if
(!
con
.
getAutoCommit
())
{
try
{
con
.
rollback
();
}
catch
(
SQLException
e
)
{
ex
=
e
;
}
}
con
.
clearWarnings
();
con
=
null
;
last
=
null
;
fireConnectionClosed
();
if
(
ex
!=
null
)
{
if
(
ex
!=
null
)
{
throw
ex
;
}
return
null
;
}
else
{
}
else
{
return
method
.
invoke
(
con
,
args
);
}
}
public
void
close
()
{
if
(
con
!=
null
)
{
public
void
close
()
{
if
(
con
!=
null
)
{
automatic
=
true
;
}
con
=
null
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/PoolingDataSource.java
View file @
f37c1c48
...
...
@@ -33,12 +33,14 @@ import java.sql.SQLException;
* <p>This implementation supports JDK 1.3 and higher.</p>
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
PoolingDataSource
extends
BaseDataSource
implements
DataSource
{
public
class
PoolingDataSource
extends
BaseDataSource
implements
DataSource
{
private
static
Map
dataSources
=
new
HashMap
();
static
PoolingDataSource
getDataSource
(
String
name
)
{
static
PoolingDataSource
getDataSource
(
String
name
)
{
return
(
PoolingDataSource
)
dataSources
.
get
(
name
);
}
...
...
@@ -56,8 +58,9 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
/**
* Gets a description of this DataSource.
*/
public
String
getDescription
()
{
return
"Pooling DataSource '"
+
dataSourceName
+
" from "
+
org
.
postgresql
.
Driver
.
getVersion
();
public
String
getDescription
()
{
return
"Pooling DataSource '"
+
dataSourceName
+
" from "
+
org
.
postgresql
.
Driver
.
getVersion
();
}
/**
...
...
@@ -68,8 +71,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Server Name cannot be changed after the DataSource has been
* used.
*/
public
void
setServerName
(
String
serverName
)
{
if
(
initialized
)
{
public
void
setServerName
(
String
serverName
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
super
.
setServerName
(
serverName
);
...
...
@@ -83,8 +88,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Database Name cannot be changed after the DataSource has been
* used.
*/
public
void
setDatabaseName
(
String
databaseName
)
{
if
(
initialized
)
{
public
void
setDatabaseName
(
String
databaseName
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
super
.
setDatabaseName
(
databaseName
);
...
...
@@ -98,8 +105,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The User cannot be changed after the DataSource has been
* used.
*/
public
void
setUser
(
String
user
)
{
if
(
initialized
)
{
public
void
setUser
(
String
user
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
super
.
setUser
(
user
);
...
...
@@ -113,8 +122,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Password cannot be changed after the DataSource has been
* used.
*/
public
void
setPassword
(
String
password
)
{
if
(
initialized
)
{
public
void
setPassword
(
String
password
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
super
.
setPassword
(
password
);
...
...
@@ -128,8 +139,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Port Number cannot be changed after the DataSource has been
* used.
*/
public
void
setPortNumber
(
int
portNumber
)
{
if
(
initialized
)
{
public
void
setPortNumber
(
int
portNumber
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
super
.
setPortNumber
(
portNumber
);
...
...
@@ -140,7 +153,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* is initialized. If you do not call initialize explicitly, it will be
* initialized the first time a connection is drawn from it.
*/
public
int
getInitialConnections
()
{
public
int
getInitialConnections
()
{
return
initialConnections
;
}
...
...
@@ -153,8 +167,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Initial Connections cannot be changed after the DataSource has been
* used.
*/
public
void
setInitialConnections
(
int
initialConnections
)
{
if
(
initialized
)
{
public
void
setInitialConnections
(
int
initialConnections
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
this
.
initialConnections
=
initialConnections
;
...
...
@@ -168,7 +184,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
*
* @return The maximum number of pooled connection allowed, or 0 for no maximum.
*/
public
int
getMaxConnections
()
{
public
int
getMaxConnections
()
{
return
maxConnections
;
}
...
...
@@ -185,8 +202,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* The Maximum Connections cannot be changed after the DataSource has been
* used.
*/
public
void
setMaxConnections
(
int
maxConnections
)
{
if
(
initialized
)
{
public
void
setMaxConnections
(
int
maxConnections
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
this
.
maxConnections
=
maxConnections
;
...
...
@@ -196,7 +215,8 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Gets the name of this DataSource. This uniquely identifies the DataSource.
* You cannot use more than one DataSource in the same VM with the same name.
*/
public
String
getDataSourceName
()
{
public
String
getDataSourceName
()
{
return
dataSourceName
;
}
...
...
@@ -212,18 +232,24 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Another PoolingDataSource with the same dataSourceName already
* exists.
*/
public
void
setDataSourceName
(
String
dataSourceName
)
{
if
(
initialized
)
{
public
void
setDataSourceName
(
String
dataSourceName
)
{
if
(
initialized
)
{
throw
new
IllegalStateException
(
"Cannot set Data Source properties after DataSource has been used"
);
}
if
(
this
.
dataSourceName
!=
null
&&
dataSourceName
!=
null
&&
dataSourceName
.
equals
(
this
.
dataSourceName
))
{
return
;
if
(
this
.
dataSourceName
!=
null
&&
dataSourceName
!=
null
&&
dataSourceName
.
equals
(
this
.
dataSourceName
))
{
return
;
}
synchronized
(
dataSources
)
{
if
(
getDataSource
(
dataSourceName
)
!=
null
)
{
throw
new
IllegalArgumentException
(
"DataSource with name '"
+
dataSourceName
+
"' already exists!"
);
synchronized
(
dataSources
)
{
if
(
getDataSource
(
dataSourceName
)
!=
null
)
{
throw
new
IllegalArgumentException
(
"DataSource with name '"
+
dataSourceName
+
"' already exists!"
);
}
if
(
this
.
dataSourceName
!=
null
)
{
if
(
this
.
dataSourceName
!=
null
)
{
dataSources
.
remove
(
this
.
dataSourceName
);
}
this
.
dataSourceName
=
dataSourceName
;
...
...
@@ -241,15 +267,18 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when the initialConnections is greater than zero, but the
* DataSource is not able to create enough physical connections.
*/
public
void
initialize
()
throws
SQLException
{
synchronized
(
lock
)
{
public
void
initialize
()
throws
SQLException
{
synchronized
(
lock
)
{
source
=
new
ConnectionPool
();
source
.
setDatabaseName
(
getDatabaseName
());
source
.
setPassword
(
getPassword
());
source
.
setPortNumber
(
getPortNumber
());
source
.
setServerName
(
getServerName
());
source
.
setUser
(
getUser
());
while
(
available
.
size
()
<
initialConnections
)
{
while
(
available
.
size
()
<
initialConnections
)
{
available
.
push
(
source
.
getPooledConnection
());
}
initialized
=
true
;
...
...
@@ -265,14 +294,17 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when no pooled connection is available, and a new physical
* connection cannot be created.
*/
public
Connection
getConnection
(
String
user
,
String
password
)
throws
SQLException
{
public
Connection
getConnection
(
String
user
,
String
password
)
throws
SQLException
{
// If this is for the default user/password, use a pooled connection
if
(
user
==
null
||
(
user
.
equals
(
getUser
())
&&
((
password
==
null
&&
getPassword
()
==
null
)
||
(
password
!=
null
&&
password
.
equals
(
getPassword
())))))
{
if
(
user
==
null
||
(
user
.
equals
(
getUser
())
&&
((
password
==
null
&&
getPassword
()
==
null
)
||
(
password
!=
null
&&
password
.
equals
(
getPassword
())))))
{
return
getConnection
();
}
// Otherwise, use a non-pooled connection
if
(!
initialized
)
{
if
(!
initialized
)
{
initialize
();
}
return
super
.
getConnection
(
user
,
password
);
...
...
@@ -286,8 +318,10 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Occurs when no pooled connection is available, and a new physical
* connection cannot be created.
*/
public
Connection
getConnection
()
throws
SQLException
{
if
(!
initialized
)
{
public
Connection
getConnection
()
throws
SQLException
{
if
(!
initialized
)
{
initialize
();
}
return
getPooledConnection
();
...
...
@@ -296,27 +330,36 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
/**
* Closes this DataSource, and all the pooled connections, whether in use or not.
*/
public
void
close
()
{
synchronized
(
lock
)
{
while
(
available
.
size
()
>
0
)
{
public
void
close
()
{
synchronized
(
lock
)
{
while
(
available
.
size
()
>
0
)
{
PooledConnectionImpl
pci
=
(
PooledConnectionImpl
)
available
.
pop
();
try
{
try
{
pci
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{}
}
available
=
null
;
while
(
used
.
size
()
>
0
)
{
while
(
used
.
size
()
>
0
)
{
PooledConnectionImpl
pci
=
(
PooledConnectionImpl
)
used
.
pop
();
pci
.
removeConnectionEventListener
(
connectionEventListener
);
try
{
try
{
pci
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{}
}
used
=
null
;
}
synchronized
(
dataSources
)
{
synchronized
(
dataSources
)
{
dataSources
.
remove
(
dataSourceName
);
}
}
...
...
@@ -326,28 +369,38 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* present, or create a new one if under the max limit. Will
* block if all used and a new one would exceed the max.
*/
private
Connection
getPooledConnection
()
throws
SQLException
{
private
Connection
getPooledConnection
()
throws
SQLException
{
PooledConnection
pc
=
null
;
synchronized
(
lock
)
{
if
(
available
==
null
)
{
synchronized
(
lock
)
{
if
(
available
==
null
)
{
throw
new
SQLException
(
"DataSource has been closed."
);
}
while
(
true
)
{
if
(
available
.
size
()
>
0
)
{
while
(
true
)
{
if
(
available
.
size
()
>
0
)
{
pc
=
(
PooledConnection
)
available
.
pop
();
used
.
push
(
pc
);
break
;
}
if
(
maxConnections
==
0
||
used
.
size
()
<
maxConnections
)
{
if
(
maxConnections
==
0
||
used
.
size
()
<
maxConnections
)
{
pc
=
source
.
getPooledConnection
();
used
.
push
(
pc
);
break
;
}
else
{
try
{
}
else
{
try
{
// Wake up every second at a minimum
lock
.
wait
(
1000L
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{}
}
}
}
...
...
@@ -360,19 +413,26 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* on a pooled connection. This is the only way connections are marked
* as unused.
*/
private
ConnectionEventListener
connectionEventListener
=
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
private
ConnectionEventListener
connectionEventListener
=
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
((
PooledConnection
)
event
.
getSource
()).
removeConnectionEventListener
(
this
);
synchronized
(
lock
)
{
if
(
available
==
null
)
{
return
;
// DataSource has been closed
synchronized
(
lock
)
{
if
(
available
==
null
)
{
return
;
// DataSource has been closed
}
boolean
removed
=
used
.
remove
(
event
.
getSource
());
if
(
removed
)
{
if
(
removed
)
{
available
.
push
(
event
.
getSource
());
// There's now a new connection available
lock
.
notify
();
}
else
{
}
else
{
// a connection error occured
}
}
...
...
@@ -382,11 +442,14 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* This is only called for fatal errors, where the physical connection is
* useless afterward and should be removed from the pool.
*/
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
((
PooledConnection
)
event
.
getSource
()).
removeConnectionEventListener
(
this
);
synchronized
(
lock
)
{
if
(
available
==
null
)
{
return
;
// DataSource has been closed
synchronized
(
lock
)
{
if
(
available
==
null
)
{
return
;
// DataSource has been closed
}
used
.
remove
(
event
.
getSource
());
// We're now at least 1 connection under the max
...
...
@@ -399,13 +462,16 @@ public class PoolingDataSource extends BaseDataSource implements DataSource {
* Adds custom properties for this DataSource to the properties defined in
* the superclass.
*/
public
Reference
getReference
()
throws
NamingException
{
public
Reference
getReference
()
throws
NamingException
{
Reference
ref
=
super
.
getReference
();
ref
.
add
(
new
StringRefAddr
(
"dataSourceName"
,
dataSourceName
));
if
(
initialConnections
>
0
)
{
if
(
initialConnections
>
0
)
{
ref
.
add
(
new
StringRefAddr
(
"initialConnections"
,
Integer
.
toString
(
initialConnections
)));
}
if
(
maxConnections
>
0
)
{
if
(
maxConnections
>
0
)
{
ref
.
add
(
new
StringRefAddr
(
"maxConnections"
,
Integer
.
toString
(
maxConnections
)));
}
return
ref
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc2/optional/SimpleDataSource.java
View file @
f37c1c48
...
...
@@ -10,13 +10,15 @@ import java.io.Serializable;
* are declared in the superclass.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
SimpleDataSource
extends
BaseDataSource
implements
Serializable
,
DataSource
{
public
class
SimpleDataSource
extends
BaseDataSource
implements
Serializable
,
DataSource
{
/**
* Gets a description of this DataSource.
*/
public
String
getDescription
()
{
return
"Non-Pooling DataSource from "
+
org
.
postgresql
.
Driver
.
getVersion
();
public
String
getDescription
()
{
return
"Non-Pooling DataSource from "
+
org
.
postgresql
.
Driver
.
getVersion
();
}
}
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java
View file @
f37c1c48
...
...
@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBytes
* @since 1.4
*/
public
int
setBytes
(
long
pos
,
byte
[]
bytes
)
throws
SQLException
{
public
int
setBytes
(
long
pos
,
byte
[]
bytes
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -51,7 +52,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBytes
* @since 1.4
*/
public
int
setBytes
(
long
pos
,
byte
[]
bytes
,
int
offset
,
int
len
)
throws
SQLException
{
public
int
setBytes
(
long
pos
,
byte
[]
bytes
,
int
offset
,
int
len
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -69,7 +71,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* @see #getBinaryStream
* @since 1.4
*/
public
java
.
io
.
OutputStream
setBinaryStream
(
long
pos
)
throws
SQLException
{
public
java
.
io
.
OutputStream
setBinaryStream
(
long
pos
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -83,7 +86,8 @@ public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdb
* <code>BLOB</code> value
* @since 1.4
*/
public
void
truncate
(
long
len
)
throws
SQLException
{
public
void
truncate
(
long
len
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java
View file @
f37c1c48
...
...
@@ -26,7 +26,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
*
* @since 1.4
*/
public
int
setString
(
long
pos
,
String
str
)
throws
SQLException
{
public
int
setString
(
long
pos
,
String
str
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -48,7 +49,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
*
* @since 1.4
*/
public
int
setString
(
long
pos
,
String
str
,
int
offset
,
int
len
)
throws
SQLException
{
public
int
setString
(
long
pos
,
String
str
,
int
offset
,
int
len
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -66,7 +68,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
*
* @since 1.4
*/
public
java
.
io
.
OutputStream
setAsciiStream
(
long
pos
)
throws
SQLException
{
public
java
.
io
.
OutputStream
setAsciiStream
(
long
pos
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -85,7 +88,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
*
* @since 1.4
*/
public
java
.
io
.
Writer
setCharacterStream
(
long
pos
)
throws
SQLException
{
public
java
.
io
.
Writer
setCharacterStream
(
long
pos
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -100,7 +104,8 @@ public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdb
*
* @since 1.4
*/
public
void
truncate
(
long
len
)
throws
SQLException
{
public
void
truncate
(
long
len
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java
View file @
f37c1c48
...
...
@@ -2,7 +2,7 @@ package org.postgresql.jdbc3;
import
java.sql.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.
1 2002/08/14 20:35:39 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2
* methods. The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
...
...
@@ -25,7 +25,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see ResultSet
* @since 1.4
*/
public
void
setHoldability
(
int
holdability
)
throws
SQLException
{
public
void
setHoldability
(
int
holdability
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -41,7 +42,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see ResultSet
* @since 1.4
*/
public
int
getHoldability
()
throws
SQLException
{
public
int
getHoldability
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -56,7 +58,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see Savepoint
* @since 1.4
*/
public
Savepoint
setSavepoint
()
throws
SQLException
{
public
Savepoint
setSavepoint
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -72,7 +75,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see Savepoint
* @since 1.4
*/
public
Savepoint
setSavepoint
(
String
name
)
throws
SQLException
{
public
Savepoint
setSavepoint
(
String
name
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -91,7 +95,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @see #rollback
* @since 1.4
*/
public
void
rollback
(
Savepoint
savepoint
)
throws
SQLException
{
public
void
rollback
(
Savepoint
savepoint
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -107,7 +112,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* savepoint in the current transaction
* @since 1.4
*/
public
void
releaseSavepoint
(
Savepoint
savepoint
)
throws
SQLException
{
public
void
releaseSavepoint
(
Savepoint
savepoint
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -143,7 +149,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4
*/
public
Statement
createStatement
(
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
int
resultSetHoldability
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -185,7 +192,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
*/
public
PreparedStatement
prepareStatement
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -224,7 +232,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
*/
public
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
,
int
resultSetHoldability
)
throws
SQLException
{
int
resultSetHoldability
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -269,7 +278,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4
*/
public
PreparedStatement
prepareStatement
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -314,7 +324,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4
*/
public
PreparedStatement
prepareStatement
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -359,7 +370,8 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
* @since 1.4
*/
public
PreparedStatement
prepareStatement
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3DatabaseMetaData.java
View file @
f37c1c48
...
...
@@ -20,7 +20,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
boolean
supportsSavepoints
()
throws
SQLException
{
public
boolean
supportsSavepoints
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -33,7 +34,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
boolean
supportsNamedParameters
()
throws
SQLException
{
public
boolean
supportsNamedParameters
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -48,7 +50,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a datanase access error occurs
* @since 1.4
*/
public
boolean
supportsMultipleOpenResults
()
throws
SQLException
{
public
boolean
supportsMultipleOpenResults
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -61,7 +64,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
boolean
supportsGetGeneratedKeys
()
throws
SQLException
{
public
boolean
supportsGetGeneratedKeys
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -106,7 +110,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @since 1.4
*/
public
ResultSet
getSuperTypes
(
String
catalog
,
String
schemaPattern
,
String
typeNamePattern
)
throws
SQLException
{
String
typeNamePattern
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -144,7 +149,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @since 1.4
*/
public
ResultSet
getSuperTables
(
String
catalog
,
String
schemaPattern
,
String
tableNamePattern
)
throws
SQLException
{
String
tableNamePattern
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -220,7 +226,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
*/
public
ResultSet
getAttributes
(
String
catalog
,
String
schemaPattern
,
String
typeNamePattern
,
String
attributeNamePattern
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -235,7 +242,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @see Connection
* @since 1.4
*/
public
boolean
supportsResultSetHoldability
(
int
holdability
)
throws
SQLException
{
public
boolean
supportsResultSetHoldability
(
int
holdability
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -249,7 +257,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
int
getResultSetHoldability
()
throws
SQLException
{
public
int
getResultSetHoldability
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -260,7 +269,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
int
getDatabaseMajorVersion
()
throws
SQLException
{
public
int
getDatabaseMajorVersion
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -271,7 +281,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
int
getDatabaseMinorVersion
()
throws
SQLException
{
public
int
getDatabaseMinorVersion
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -283,7 +294,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
int
getJDBCMajorVersion
()
throws
SQLException
{
public
int
getJDBCMajorVersion
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -295,7 +307,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
int
getJDBCMinorVersion
()
throws
SQLException
{
public
int
getJDBCMinorVersion
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -308,7 +321,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public
int
getSQLStateType
()
throws
SQLException
{
public
int
getSQLStateType
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -320,7 +334,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLException if a database access error occurs
* @since 1.4
*/
public
boolean
locatorsUpdateCopy
()
throws
SQLException
{
public
boolean
locatorsUpdateCopy
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -332,7 +347,8 @@ public abstract class AbstractJdbc3DatabaseMetaData extends org.postgresql.jdbc2
* @throws SQLExcpetion if a database access error occurs
* @since 1.4
*/
public
boolean
supportsStatementPooling
()
throws
SQLException
{
public
boolean
supportsStatementPooling
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
View file @
f37c1c48
...
...
@@ -4,14 +4,16 @@ package org.postgresql.jdbc3;
import
java.sql.*
;
import
java.util.Vector
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.
1 2002/08/14 20:35:39 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2
* methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet
*/
public
abstract
class
AbstractJdbc3ResultSet
extends
org
.
postgresql
.
jdbc2
.
AbstractJdbc2ResultSet
{
public
abstract
class
AbstractJdbc3ResultSet
extends
org
.
postgresql
.
jdbc2
.
AbstractJdbc2ResultSet
{
public
AbstractJdbc3ResultSet
(
org
.
postgresql
.
PGConnection
conn
,
Statement
statement
,
org
.
postgresql
.
Field
[]
fields
,
Vector
tuples
,
String
status
,
int
updateCount
,
long
insertOID
,
boolean
binaryCursor
)
{
public
AbstractJdbc3ResultSet
(
org
.
postgresql
.
PGConnection
conn
,
Statement
statement
,
org
.
postgresql
.
Field
[]
fields
,
Vector
tuples
,
String
status
,
int
updateCount
,
long
insertOID
,
boolean
binaryCursor
)
{
super
(
conn
,
statement
,
fields
,
tuples
,
status
,
updateCount
,
insertOID
,
binaryCursor
);
}
...
...
@@ -28,7 +30,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* or if a URL is malformed
* @since 1.4
*/
public
java
.
net
.
URL
getURL
(
int
columnIndex
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
int
columnIndex
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -45,7 +48,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* or if a URL is malformed
* @since 1.4
*/
public
java
.
net
.
URL
getURL
(
String
columnName
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
String
columnName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -61,7 +65,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateRef
(
int
columnIndex
,
java
.
sql
.
Ref
x
)
throws
SQLException
{
public
void
updateRef
(
int
columnIndex
,
java
.
sql
.
Ref
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -77,7 +82,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateRef
(
String
columnName
,
java
.
sql
.
Ref
x
)
throws
SQLException
{
public
void
updateRef
(
String
columnName
,
java
.
sql
.
Ref
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -93,7 +99,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateBlob
(
int
columnIndex
,
java
.
sql
.
Blob
x
)
throws
SQLException
{
public
void
updateBlob
(
int
columnIndex
,
java
.
sql
.
Blob
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -109,7 +116,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateBlob
(
String
columnName
,
java
.
sql
.
Blob
x
)
throws
SQLException
{
public
void
updateBlob
(
String
columnName
,
java
.
sql
.
Blob
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -125,7 +133,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateClob
(
int
columnIndex
,
java
.
sql
.
Clob
x
)
throws
SQLException
{
public
void
updateClob
(
int
columnIndex
,
java
.
sql
.
Clob
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -141,7 +150,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateClob
(
String
columnName
,
java
.
sql
.
Clob
x
)
throws
SQLException
{
public
void
updateClob
(
String
columnName
,
java
.
sql
.
Clob
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -157,7 +167,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateArray
(
int
columnIndex
,
java
.
sql
.
Array
x
)
throws
SQLException
{
public
void
updateArray
(
int
columnIndex
,
java
.
sql
.
Array
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -173,7 +184,8 @@ public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
updateArray
(
String
columnName
,
java
.
sql
.
Array
x
)
throws
SQLException
{
public
void
updateArray
(
String
columnName
,
java
.
sql
.
Array
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import java.math.BigDecimal;
import
java.sql.*
;
import
java.util.Calendar
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.
1 2002/08/14 20:35:39 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Statement.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2Statement which provides the jdbc2
* methods. The real Statement class (for jdbc2) is org.postgresql.jdbc3.Jdbc3Statement
...
...
@@ -48,7 +48,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
* @see #execute
*/
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
public
boolean
getMoreResults
(
int
current
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -63,7 +64,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
public
ResultSet
getGeneratedKeys
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -89,7 +91,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* the given constant is not one of those allowed
* @since 1.4
*/
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -111,7 +114,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* statement returns a <code>ResultSet</code> object
* @since 1.4
*/
public
int
executeUpdate
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -132,7 +136,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*
* @since 1.4
*/
public
int
executeUpdate
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
public
int
executeUpdate
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -172,7 +177,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*
* @since 1.4
*/
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
public
boolean
execute
(
String
sql
,
int
autoGeneratedKeys
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -211,7 +217,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*
* @since 1.4
*/
public
boolean
execute
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
public
boolean
execute
(
String
sql
,
int
columnIndexes
[])
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -251,7 +258,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*
* @since 1.4
*/
public
boolean
execute
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
public
boolean
execute
(
String
sql
,
String
columnNames
[])
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -265,7 +273,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*
* @since 1.4
*/
public
int
getResultSetHoldability
()
throws
SQLException
{
public
int
getResultSetHoldability
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -279,7 +288,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
setURL
(
int
parameterIndex
,
java
.
net
.
URL
x
)
throws
SQLException
{
public
void
setURL
(
int
parameterIndex
,
java
.
net
.
URL
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -294,7 +304,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see ParameterMetaData
* @since 1.4
*/
public
ParameterMetaData
getParameterMetaData
()
throws
SQLException
{
public
ParameterMetaData
getParameterMetaData
()
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -323,7 +334,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see Types
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -349,7 +361,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see Types
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
int
scale
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -388,7 +401,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
registerOutParameter
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -406,7 +420,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setURL
* @since 1.4
*/
public
java
.
net
.
URL
getURL
(
int
parameterIndex
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
int
parameterIndex
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -422,7 +437,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getURL
* @since 1.4
*/
public
void
setURL
(
String
parameterName
,
java
.
net
.
URL
val
)
throws
SQLException
{
public
void
setURL
(
String
parameterName
,
java
.
net
.
URL
val
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -436,7 +452,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
void
setNull
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
public
void
setNull
(
String
parameterName
,
int
sqlType
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -451,7 +468,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBoolean
* @since 1.4
*/
public
void
setBoolean
(
String
parameterName
,
boolean
x
)
throws
SQLException
{
public
void
setBoolean
(
String
parameterName
,
boolean
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -466,7 +484,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getByte
* @since 1.4
*/
public
void
setByte
(
String
parameterName
,
byte
x
)
throws
SQLException
{
public
void
setByte
(
String
parameterName
,
byte
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -481,7 +500,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getShort
* @since 1.4
*/
public
void
setShort
(
String
parameterName
,
short
x
)
throws
SQLException
{
public
void
setShort
(
String
parameterName
,
short
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -496,7 +516,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getInt
* @since 1.4
*/
public
void
setInt
(
String
parameterName
,
int
x
)
throws
SQLException
{
public
void
setInt
(
String
parameterName
,
int
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -511,7 +532,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getLong
* @since 1.4
*/
public
void
setLong
(
String
parameterName
,
long
x
)
throws
SQLException
{
public
void
setLong
(
String
parameterName
,
long
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -526,7 +548,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getFloat
* @since 1.4
*/
public
void
setFloat
(
String
parameterName
,
float
x
)
throws
SQLException
{
public
void
setFloat
(
String
parameterName
,
float
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -541,7 +564,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getDouble
* @since 1.4
*/
public
void
setDouble
(
String
parameterName
,
double
x
)
throws
SQLException
{
public
void
setDouble
(
String
parameterName
,
double
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -557,7 +581,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBigDecimal
* @since 1.4
*/
public
void
setBigDecimal
(
String
parameterName
,
BigDecimal
x
)
throws
SQLException
{
public
void
setBigDecimal
(
String
parameterName
,
BigDecimal
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -575,7 +600,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getString
* @since 1.4
*/
public
void
setString
(
String
parameterName
,
String
x
)
throws
SQLException
{
public
void
setString
(
String
parameterName
,
String
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -592,7 +618,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getBytes
* @since 1.4
*/
public
void
setBytes
(
String
parameterName
,
byte
x
[])
throws
SQLException
{
public
void
setBytes
(
String
parameterName
,
byte
x
[])
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -608,7 +635,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setDate
(
String
parameterName
,
java
.
sql
.
Date
x
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -624,7 +652,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setTime
(
String
parameterName
,
java
.
sql
.
Time
x
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -641,7 +670,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setTimestamp
(
String
parameterName
,
java
.
sql
.
Timestamp
x
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -665,7 +695,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setAsciiStream
(
String
parameterName
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -688,7 +719,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setBinaryStream
(
String
parameterName
,
java
.
io
.
InputStream
x
,
int
length
)
throws
SQLException
{
int
length
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -725,7 +757,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
,
int
scale
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -743,7 +776,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setObject
(
String
parameterName
,
Object
x
,
int
targetSqlType
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -779,7 +813,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #getObject
* @since 1.4
*/
public
void
setObject
(
String
parameterName
,
Object
x
)
throws
SQLException
{
public
void
setObject
(
String
parameterName
,
Object
x
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -806,7 +841,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
*/
public
void
setCharacterStream
(
String
parameterName
,
java
.
io
.
Reader
reader
,
int
length
)
throws
SQLException
{
int
length
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -829,7 +865,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setDate
(
String
parameterName
,
java
.
sql
.
Date
x
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -852,7 +889,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setTime
(
String
parameterName
,
java
.
sql
.
Time
x
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -875,7 +913,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setTimestamp
(
String
parameterName
,
java
.
sql
.
Timestamp
x
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -909,7 +948,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
void
setNull
(
String
parameterName
,
int
sqlType
,
String
typeName
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -930,7 +970,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setString
* @since 1.4
*/
public
String
getString
(
String
parameterName
)
throws
SQLException
{
public
String
getString
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -944,7 +985,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBoolean
* @since 1.4
*/
public
boolean
getBoolean
(
String
parameterName
)
throws
SQLException
{
public
boolean
getBoolean
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -958,7 +1000,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setByte
* @since 1.4
*/
public
byte
getByte
(
String
parameterName
)
throws
SQLException
{
public
byte
getByte
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -972,7 +1015,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setShort
* @since 1.4
*/
public
short
getShort
(
String
parameterName
)
throws
SQLException
{
public
short
getShort
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -987,7 +1031,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setInt
* @since 1.4
*/
public
int
getInt
(
String
parameterName
)
throws
SQLException
{
public
int
getInt
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1002,7 +1047,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setLong
* @since 1.4
*/
public
long
getLong
(
String
parameterName
)
throws
SQLException
{
public
long
getLong
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1016,7 +1062,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setFloat
* @since 1.4
*/
public
float
getFloat
(
String
parameterName
)
throws
SQLException
{
public
float
getFloat
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1030,7 +1077,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setDouble
* @since 1.4
*/
public
double
getDouble
(
String
parameterName
)
throws
SQLException
{
public
double
getDouble
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1045,7 +1093,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBytes
* @since 1.4
*/
public
byte
[]
getBytes
(
String
parameterName
)
throws
SQLException
{
public
byte
[]
getBytes
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1059,7 +1108,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setDate
* @since 1.4
*/
public
java
.
sql
.
Date
getDate
(
String
parameterName
)
throws
SQLException
{
public
java
.
sql
.
Date
getDate
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1073,7 +1123,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setTime
* @since 1.4
*/
public
java
.
sql
.
Time
getTime
(
String
parameterName
)
throws
SQLException
{
public
java
.
sql
.
Time
getTime
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1087,7 +1138,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setTimestamp
* @since 1.4
*/
public
java
.
sql
.
Timestamp
getTimestamp
(
String
parameterName
)
throws
SQLException
{
public
java
.
sql
.
Timestamp
getTimestamp
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1108,7 +1160,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setObject
* @since 1.4
*/
public
Object
getObject
(
String
parameterName
)
throws
SQLException
{
public
Object
getObject
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1123,7 +1176,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setBigDecimal
* @since 1.4
*/
public
BigDecimal
getBigDecimal
(
String
parameterName
)
throws
SQLException
{
public
BigDecimal
getBigDecimal
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1144,7 +1198,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setObject
* @since 1.4
*/
public
Object
getObject
(
String
parameterName
,
java
.
util
.
Map
map
)
throws
SQLException
{
public
Object
getObject
(
String
parameterName
,
java
.
util
.
Map
map
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1159,7 +1214,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
Ref
getRef
(
String
parameterName
)
throws
SQLException
{
public
Ref
getRef
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1174,7 +1230,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
Blob
getBlob
(
String
parameterName
)
throws
SQLException
{
public
Blob
getBlob
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1188,7 +1245,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
Clob
getClob
(
String
parameterName
)
throws
SQLException
{
public
Clob
getClob
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1203,7 +1261,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @exception SQLException if a database access error occurs
* @since 1.4
*/
public
Array
getArray
(
String
parameterName
)
throws
SQLException
{
public
Array
getArray
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1227,7 +1286,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
java
.
sql
.
Date
getDate
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1251,7 +1311,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
java
.
sql
.
Time
getTime
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1276,7 +1337,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @since 1.4
*/
public
java
.
sql
.
Timestamp
getTimestamp
(
String
parameterName
,
Calendar
cal
)
throws
SQLException
{
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
@@ -1293,7 +1355,8 @@ public abstract class AbstractJdbc3Statement extends org.postgresql.jdbc2.Abstra
* @see #setURL
* @since 1.4
*/
public
java
.
net
.
URL
getURL
(
String
parameterName
)
throws
SQLException
{
public
java
.
net
.
URL
getURL
(
String
parameterName
)
throws
SQLException
{
throw
org
.
postgresql
.
Driver
.
notImplemented
();
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Connection.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.util.Vector;
import
java.util.Hashtable
;
import
org.postgresql.Field
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.
1 2002/08/14 20:35:40 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Connection.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Connection interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Connection or one of it's parents
...
...
@@ -33,7 +33,7 @@ public class Jdbc3Connection extends org.postgresql.jdbc3.AbstractJdbc3Connectio
public
java
.
sql
.
CallableStatement
prepareCall
(
String
sql
,
int
resultSetType
,
int
resultSetConcurrency
)
throws
SQLException
{
Jdbc3CallableStatement
s
=
new
Jdbc3CallableStatement
(
this
,
sql
);
Jdbc3CallableStatement
s
=
new
Jdbc3CallableStatement
(
this
,
sql
);
s
.
setResultSetType
(
resultSetType
);
s
.
setResultSetConcurrency
(
resultSetConcurrency
);
return
s
;
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3DatabaseMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import java.sql.*;
import
java.util.Vector
;
import
org.postgresql.Field
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.
1 2002/08/14 20:35:40 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.ResultSet interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
...
...
@@ -23,11 +23,13 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
return
new
Jdbc3ResultSetMetaData
(
rows
,
fields
);
}
public
java
.
sql
.
Clob
getClob
(
int
i
)
throws
SQLException
{
public
java
.
sql
.
Clob
getClob
(
int
i
)
throws
SQLException
{
return
new
Jdbc3Clob
(
connection
,
getInt
(
i
));
}
public
java
.
sql
.
Blob
getBlob
(
int
i
)
throws
SQLException
{
public
java
.
sql
.
Blob
getBlob
(
int
i
)
throws
SQLException
{
return
new
Jdbc3Blob
(
connection
,
getInt
(
i
));
}
...
...
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3ResultSetMetaData.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
View file @
f37c1c48
...
...
@@ -3,7 +3,7 @@ package org.postgresql.jdbc3;
import
java.sql.*
;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.
1 2002/08/14 20:35:40 barry
Exp $
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.
2 2002/09/06 21:23:06 momjian
Exp $
* This class implements the java.sql.Statement interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents
...
...
src/interfaces/jdbc/org/postgresql/largeobject/LargeObject.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/largeobject/LargeObjectManager.java
View file @
f37c1c48
...
...
@@ -118,7 +118,8 @@ public class LargeObjectManager
fp
.
addFunctions
(
res
);
res
.
close
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Large Object initialised"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Large Object initialised"
);
}
/*
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java
View file @
f37c1c48
...
...
@@ -23,7 +23,7 @@ public class CallableStmtTest extends TestCase
con
=
TestUtil
.
openDB
();
Statement
stmt
=
con
.
createStatement
();
stmt
.
execute
(
"CREATE OR REPLACE FUNCTION testspg__getString (varchar) "
+
"RETURNS varchar AS ' DECLARE inString alias for $1; begin "
+
"RETURNS varchar AS ' DECLARE inString alias for $1; begin "
+
"return ''bob''; end; ' LANGUAGE 'plpgsql';"
);
stmt
.
execute
(
"CREATE OR REPLACE FUNCTION testspg__getDouble (float) "
+
"RETURNS float AS ' DECLARE inString alias for $1; begin "
+
...
...
@@ -54,7 +54,8 @@ public class CallableStmtTest extends TestCase
//testGetString ();
//}
public
void
testGetDouble
()
throws
Throwable
{
public
void
testGetDouble
()
throws
Throwable
{
// System.out.println ("Testing CallableStmt Types.DOUBLE");
CallableStatement
call
=
con
.
prepareCall
(
func
+
pkgName
+
"getDouble (?) }"
);
call
.
setDouble
(
2
,
(
double
)
3.04
);
...
...
@@ -64,7 +65,8 @@ public class CallableStmtTest extends TestCase
assertTrue
(
"correct return from getString ()"
,
result
==
42.42
);
}
public
void
testGetInt
()
throws
Throwable
{
public
void
testGetInt
()
throws
Throwable
{
// System.out.println ("Testing CallableStmt Types.INTEGER");
CallableStatement
call
=
con
.
prepareCall
(
func
+
pkgName
+
"getInt (?) }"
);
call
.
setInt
(
2
,
4
);
...
...
@@ -74,7 +76,8 @@ public class CallableStmtTest extends TestCase
assertTrue
(
"correct return from getString ()"
,
result
==
42
);
}
public
void
testGetNumeric
()
throws
Throwable
{
public
void
testGetNumeric
()
throws
Throwable
{
// System.out.println ("Testing CallableStmt Types.NUMERIC");
CallableStatement
call
=
con
.
prepareCall
(
func
+
pkgName
+
"getNumeric (?) }"
);
call
.
setBigDecimal
(
2
,
new
java
.
math
.
BigDecimal
(
4
));
...
...
@@ -85,7 +88,8 @@ public class CallableStmtTest extends TestCase
result
.
equals
(
new
java
.
math
.
BigDecimal
(
42
)));
}
public
void
testGetString
()
throws
Throwable
{
public
void
testGetString
()
throws
Throwable
{
// System.out.println ("Testing CallableStmt Types.VARCHAR");
CallableStatement
call
=
con
.
prepareCall
(
func
+
pkgName
+
"getString (?) }"
);
call
.
setString
(
2
,
"foo"
);
...
...
@@ -96,20 +100,25 @@ public class CallableStmtTest extends TestCase
}
public
void
testBadStmt
()
throws
Throwable
{
public
void
testBadStmt
()
throws
Throwable
{
tryOneBadStmt
(
"{ ?= "
+
pkgName
+
"getString (?) }"
);
tryOneBadStmt
(
"{ ?= call getString (?) "
);
tryOneBadStmt
(
"{ = ? call getString (?); }"
);
}
protected
void
tryOneBadStmt
(
String
sql
)
throws
Throwable
{
protected
void
tryOneBadStmt
(
String
sql
)
throws
Throwable
{
boolean
wasCaught
=
false
;
try
{
try
{
CallableStatement
call
=
con
.
prepareCall
(
sql
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
wasCaught
=
true
;
// good -> this statement was missing something
}
assertTrue
(
"bad statment ('"
+
sql
+
"')was not caught"
,
wasCaught
);
assertTrue
(
"bad statment ('"
+
sql
+
"')was not caught"
,
wasCaught
);
}
}
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
View file @
f37c1c48
...
...
@@ -9,7 +9,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
* $Id: DatabaseMetaDataTest.java,v 1.1
2 2002/08/23 20:45:49 barry
Exp $
* $Id: DatabaseMetaDataTest.java,v 1.1
3 2002/09/06 21:23:06 momjian
Exp $
*/
public
class
DatabaseMetaDataTest
extends
TestCase
...
...
@@ -248,7 +248,7 @@ public class DatabaseMetaDataTest extends TestCase
ResultSet
rs
=
dbmd
.
getCrossReference
(
null
,
""
,
"vv"
,
null
,
""
,
"ww"
);
for
(
int
j
=
1
;
rs
.
next
();
j
++
)
for
(
int
j
=
1
;
rs
.
next
();
j
++
)
{
String
pkTableName
=
rs
.
getString
(
"PKTABLE_NAME"
);
...
...
@@ -291,8 +291,8 @@ public class DatabaseMetaDataTest extends TestCase
TestUtil
.
createTable
(
con1
,
"people"
,
"id int4 primary key, name text"
);
TestUtil
.
createTable
(
con1
,
"policy"
,
"id int4 primary key, name text"
);
TestUtil
.
createTable
(
con1
,
"users"
,
"id int4 primary key, people_id int4, policy_id int4,"
+
"CONSTRAINT people FOREIGN KEY (people_id) references people(id),"
+
TestUtil
.
createTable
(
con1
,
"users"
,
"id int4 primary key, people_id int4, policy_id int4,"
+
"CONSTRAINT people FOREIGN KEY (people_id) references people(id),"
+
"constraint policy FOREIGN KEY (policy_id) references policy(id)"
);
...
...
@@ -324,7 +324,7 @@ public class DatabaseMetaDataTest extends TestCase
}
assertTrue
(
j
==
2
);
assertTrue
(
j
==
2
);
rs
=
dbmd
.
getExportedKeys
(
null
,
""
,
"people"
);
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
View file @
f37c1c48
...
...
@@ -6,7 +6,7 @@ import java.sql.*;
import
java.math.BigDecimal
;
/*
* $Id: JBuilderTest.java,v 1.
6 2002/08/14 20:35:40 barry
Exp $
* $Id: JBuilderTest.java,v 1.
7 2002/09/06 21:23:06 momjian
Exp $
*
* Some simple tests to check that the required components needed for JBuilder
* stay working
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import
java.sql.*
;
/*
* $Id: MiscTest.java,v 1.
7 2002/08/14 20:35:40 barry
Exp $
* $Id: MiscTest.java,v 1.
8 2002/09/06 21:23:06 momjian
Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
...
...
@@ -66,13 +66,14 @@ public class MiscTest extends TestCase
con
.
commit
();
}
catch
(
Exception
ex
)
{
}
{}
try
{
con
.
commit
();
con
.
close
();
}
catch
(
Exception
ex
)
{}
}
catch
(
Exception
ex
)
{}
}
public
void
xtestLocking
()
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import
java.sql.*
;
/*
* $Id: TimestampTest.java,v 1.
8 2002/08/14 20:35:40 barry
Exp $
* $Id: TimestampTest.java,v 1.
9 2002/09/06 21:23:06 momjian
Exp $
*
* Test get/setTimestamp for both timestamp with time zone and
* timestamp without time zone datatypes
...
...
@@ -49,9 +49,9 @@ public class TimestampTest extends TestCase
Statement
stmt
=
con
.
createStatement
();
//Insert the three timestamp values in raw pg format
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS1WTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS2WTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS3WTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS1WTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS2WTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWTZ_TABLE
,
"'"
+
TS3WTZ_PGFORMAT
+
"'"
)));
// Fall through helper
timestampTestWTZ
();
...
...
@@ -114,9 +114,9 @@ public class TimestampTest extends TestCase
Statement
stmt
=
con
.
createStatement
();
//Insert the three timestamp values in raw pg format
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS1WOTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS2WOTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS3WOTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS1WOTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS2WOTZ_PGFORMAT
+
"'"
)));
assertEquals
(
1
,
stmt
.
executeUpdate
(
TestUtil
.
insertSQL
(
TSWOTZ_TABLE
,
"'"
+
TS3WOTZ_PGFORMAT
+
"'"
)));
// Fall through helper
timestampTestWOTZ
();
...
...
@@ -238,7 +238,8 @@ public class TimestampTest extends TestCase
{
java
.
sql
.
Timestamp
l_return
=
null
;
java
.
text
.
DateFormat
l_df
;
try
{
try
{
String
l_ts
;
l_ts
=
TestUtil
.
fix
(
y
,
4
)
+
"-"
+
TestUtil
.
fix
(
m
,
2
)
+
"-"
+
...
...
@@ -247,16 +248,21 @@ public class TimestampTest extends TestCase
TestUtil
.
fix
(
mn
,
2
)
+
":"
+
TestUtil
.
fix
(
se
,
2
)
+
" "
;
if
(
tz
==
null
)
{
if
(
tz
==
null
)
{
l_df
=
new
java
.
text
.
SimpleDateFormat
(
"y-M-d H:m:s"
);
}
else
{
}
else
{
l_ts
=
l_ts
+
tz
;
l_df
=
new
java
.
text
.
SimpleDateFormat
(
"y-M-d H:m:s z"
);
}
java
.
util
.
Date
l_date
=
l_df
.
parse
(
l_ts
);
l_return
=
new
java
.
sql
.
Timestamp
(
l_date
.
getTime
());
l_return
.
setNanos
(
f
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
());
}
return
l_return
;
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
View file @
f37c1c48
...
...
@@ -26,8 +26,8 @@ public class UpdateableResultTest extends TestCase
try
{
Connection
con
=
TestUtil
.
openDB
();
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
// put some dummy data into second
Statement
st2
=
con
.
createStatement
();
...
...
@@ -44,8 +44,8 @@ public class UpdateableResultTest extends TestCase
rs
.
insertRow
();
rs
.
first
();
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
2
);
...
...
@@ -54,7 +54,7 @@ public class UpdateableResultTest extends TestCase
rs
.
deleteRow
();
rs
.
moveToInsertRow
();
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateString
(
"name"
,
"paul"
);
rs
.
insertRow
();
...
...
@@ -69,17 +69,18 @@ public class UpdateableResultTest extends TestCase
rs
=
st
.
executeQuery
(
"select id1, id, name, name1 from updateable, second"
);
try
{
while
(
rs
.
next
()
)
while
(
rs
.
next
()
)
{
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateRow
();
}
assertTrue
(
"should not get here, update should fail"
,
false
);
}
catch
(
SQLException
ex
){}
catch
(
SQLException
ex
)
{}
try
{
...
...
@@ -115,14 +116,14 @@ public class UpdateableResultTest extends TestCase
}
}
catch
(
SQLException
ex
)
catch
(
SQLException
ex
)
{
fail
(
ex
.
getMessage
());
}
st
.
close
();
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
closeDB
(
con
);
}
catch
(
Exception
ex
)
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
View file @
f37c1c48
...
...
@@ -15,16 +15,18 @@ import java.sql.*;
* tests.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
abstract
class
BaseDataSourceTest
extends
TestCase
{
public
abstract
class
BaseDataSourceTest
extends
TestCase
{
protected
Connection
con
;
protected
BaseDataSource
bds
;
/**
* Constructor required by JUnit
*/
public
BaseDataSourceTest
(
String
name
)
{
public
BaseDataSourceTest
(
String
name
)
{
super
(
name
);
}
...
...
@@ -32,7 +34,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Creates a test table using a standard connection (not from a
* DataSource).
*/
protected
void
setUp
()
throws
Exception
{
protected
void
setUp
()
throws
Exception
{
con
=
JDBC2Tests
.
openDB
();
JDBC2Tests
.
createTable
(
con
,
"poolingtest"
,
"id int4 not null primary key, name varchar(50)"
);
Statement
stmt
=
con
.
createStatement
();
...
...
@@ -45,7 +48,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Removes the test table using a standard connection (not from
* a DataSource)
*/
protected
void
tearDown
()
throws
Exception
{
protected
void
tearDown
()
throws
Exception
{
con
=
JDBC2Tests
.
openDB
();
JDBC2Tests
.
dropTable
(
con
,
"poolingtest"
);
JDBC2Tests
.
closeDB
(
con
);
...
...
@@ -54,7 +58,8 @@ public abstract class BaseDataSourceTest extends TestCase {
/**
* Gets a connection from the current BaseDataSource
*/
protected
Connection
getDataSourceConnection
()
throws
SQLException
{
protected
Connection
getDataSourceConnection
()
throws
SQLException
{
initializeDataSource
();
return
bds
.
getConnection
();
}
...
...
@@ -69,7 +74,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* Test to make sure you can instantiate and configure the
* appropriate DataSource
*/
public
void
testCreateDataSource
()
{
public
void
testCreateDataSource
()
{
initializeDataSource
();
}
...
...
@@ -77,11 +83,15 @@ public abstract class BaseDataSourceTest extends TestCase {
* Test to make sure you can get a connection from the DataSource,
* which in turn means the DataSource was able to open it.
*/
public
void
testGetConnection
()
{
try
{
public
void
testGetConnection
()
{
try
{
con
=
getDataSourceConnection
();
con
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -90,26 +100,35 @@ public abstract class BaseDataSourceTest extends TestCase {
* A simple test to make sure you can execute SQL using the
* Connection from the DataSource
*/
public
void
testUseConnection
()
{
try
{
public
void
testUseConnection
()
{
try
{
con
=
getDataSourceConnection
();
Statement
st
=
con
.
createStatement
();
ResultSet
rs
=
st
.
executeQuery
(
"SELECT COUNT(*) FROM poolingtest"
);
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
int
count
=
rs
.
getInt
(
1
);
if
(
rs
.
next
())
{
if
(
rs
.
next
())
{
fail
(
"Should only have one row in SELECT COUNT result set"
);
}
if
(
count
!=
2
)
{
fail
(
"Count returned "
+
count
+
" expecting 2"
);
if
(
count
!=
2
)
{
fail
(
"Count returned "
+
count
+
" expecting 2"
);
}
}
}
else
{
else
{
fail
(
"Should have one row in SELECT COUNT result set"
);
}
rs
.
close
();
st
.
close
();
con
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -118,13 +137,17 @@ public abstract class BaseDataSourceTest extends TestCase {
* A test to make sure you can execute DDL SQL using the
* Connection from the DataSource.
*/
public
void
testDdlOverConnection
()
{
try
{
public
void
testDdlOverConnection
()
{
try
{
con
=
getDataSourceConnection
();
JDBC2Tests
.
dropTable
(
con
,
"poolingtest"
);
JDBC2Tests
.
createTable
(
con
,
"poolingtest"
,
"id int4 not null primary key, name varchar(50)"
);
con
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -134,8 +157,10 @@ public abstract class BaseDataSourceTest extends TestCase {
* current DataSource. Obviously need to be overridden in the case
* of a pooling Datasource.
*/
public
void
testNotPooledConnection
()
{
try
{
public
void
testNotPooledConnection
()
{
try
{
con
=
getDataSourceConnection
();
String
name
=
con
.
toString
();
con
.
close
();
...
...
@@ -143,7 +168,9 @@ public abstract class BaseDataSourceTest extends TestCase {
String
name2
=
con
.
toString
();
con
.
close
();
assertTrue
(!
name
.
equals
(
name2
));
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -154,7 +181,8 @@ public abstract class BaseDataSourceTest extends TestCase {
* should ideally test both Serializable and Referenceable
* mechanisms. Will probably be multiple tests when implemented.
*/
public
void
testJndi
()
{
public
void
testJndi
()
{
// TODO: Put the DS in JNDI, retrieve it, and try some of this stuff again
}
}
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
View file @
f37c1c48
...
...
@@ -11,27 +11,34 @@ import java.sql.*;
* interface to the PooledConnection is through the CPDS.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
ConnectionPoolTest
extends
BaseDataSourceTest
{
public
class
ConnectionPoolTest
extends
BaseDataSourceTest
{
/**
* Constructor required by JUnit
*/
public
ConnectionPoolTest
(
String
name
)
{
public
ConnectionPoolTest
(
String
name
)
{
super
(
name
);
}
/**
* Creates and configures a ConnectionPool
*/
protected
void
initializeDataSource
()
{
if
(
bds
==
null
)
{
protected
void
initializeDataSource
()
{
if
(
bds
==
null
)
{
bds
=
new
ConnectionPool
();
String
db
=
JDBC2Tests
.
getURL
();
if
(
db
.
indexOf
(
'/'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
'/'
)+
1
);
}
else
if
(
db
.
indexOf
(
':'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
':'
)+
1
);
if
(
db
.
indexOf
(
'/'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
'/'
)
+
1
);
}
else
if
(
db
.
indexOf
(
':'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
':'
)
+
1
);
}
bds
.
setDatabaseName
(
db
);
bds
.
setUser
(
JDBC2Tests
.
getUser
());
...
...
@@ -44,7 +51,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* order to test the middleware/server interface, we need to deal
* with PooledConnections. Some tests use each.
*/
protected
PooledConnection
getPooledConnection
()
throws
SQLException
{
protected
PooledConnection
getPooledConnection
()
throws
SQLException
{
initializeDataSource
();
return
((
ConnectionPool
)
bds
).
getPooledConnection
();
}
...
...
@@ -57,22 +65,29 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* would never by closed. Probably not a disaster during testing, but
* you never know.
*/
protected
Connection
getDataSourceConnection
()
throws
SQLException
{
protected
Connection
getDataSourceConnection
()
throws
SQLException
{
initializeDataSource
();
final
PooledConnection
pc
=
getPooledConnection
();
// Since the pooled connection won't be reused in these basic tests, close it when the connection is closed
pc
.
addConnectionEventListener
(
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
try
{
pc
.
addConnectionEventListener
(
new
ConnectionEventListener
()
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
try
{
pc
.
close
();
}
catch
(
SQLException
e
)
{
fail
(
"Unable to close PooledConnection: "
+
e
);
}
catch
(
SQLException
e
)
{
fail
(
"Unable to close PooledConnection: "
+
e
);
}
}
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{}
}
}
);
);
return
pc
.
getConnection
();
}
...
...
@@ -82,8 +97,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* physical connection. Depends on the implementation of toString
* for the connection handle.
*/
public
void
testPoolReuse
()
{
try
{
public
void
testPoolReuse
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
con
=
pc
.
getConnection
();
String
name
=
con
.
toString
();
...
...
@@ -93,7 +110,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con
.
close
();
pc
.
close
();
assertTrue
(
"Physical connection doesn't appear to be reused across PooledConnection wrappers"
,
name
.
equals
(
name2
));
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -104,22 +123,32 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* out is closed. See JDBC 2.0 Optional Package spec section
* 6.2.3
*/
public
void
testPoolCloseOldWrapper
()
{
try
{
public
void
testPoolCloseOldWrapper
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
con
=
pc
.
getConnection
();
Connection
con2
=
pc
.
getConnection
();
try
{
try
{
con
.
createStatement
();
fail
(
"Original connection wrapper should be closed when new connection wrapper is generated"
);
}
catch
(
SQLException
e
)
{}
try
{
}
catch
(
SQLException
e
)
{}
try
{
con
.
close
();
fail
(
"Original connection wrapper should be closed when new connection wrapper is generated"
);
}
catch
(
SQLException
e
)
{}
}
catch
(
SQLException
e
)
{}
con2
.
close
();
pc
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -130,15 +159,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* the same physical connection. See JDBC 2.0 Optional Pacakge spec
* section 6.2.2
*/
public
void
testPoolNewWrapper
()
{
try
{
public
void
testPoolNewWrapper
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
con
=
pc
.
getConnection
();
Connection
con2
=
pc
.
getConnection
();
con2
.
close
();
pc
.
close
();
assertTrue
(
"Two calls to PooledConnection.getConnection should not return the same connection wrapper"
,
con
!=
con2
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -148,8 +181,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* connection handle is closed. Also checks that events are not
* fired after a given handle has been closed once.
*/
public
void
testCloseEvent
()
{
try
{
public
void
testCloseEvent
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
CountClose
cc
=
new
CountClose
();
pc
.
addConnectionEventListener
(
cc
);
...
...
@@ -165,14 +200,19 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con
.
close
();
assertTrue
(
cc
.
getCount
()
==
2
);
assertTrue
(
cc
.
getErrorCount
()
==
0
);
try
{
try
{
con
.
close
();
fail
(
"Should not be able to close a connection wrapper twice"
);
}
catch
(
SQLException
e
)
{}
}
catch
(
SQLException
e
)
{}
assertTrue
(
cc
.
getCount
()
==
2
);
assertTrue
(
cc
.
getErrorCount
()
==
0
);
pc
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -181,8 +221,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* Makes sure that close events are not fired after a listener has
* been removed.
*/
public
void
testNoCloseEvent
()
{
try
{
public
void
testNoCloseEvent
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
CountClose
cc
=
new
CountClose
();
pc
.
addConnectionEventListener
(
cc
);
...
...
@@ -199,7 +241,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con
.
close
();
assertTrue
(
cc
.
getCount
()
==
1
);
assertTrue
(
cc
.
getErrorCount
()
==
0
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -209,8 +253,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* events. Sometimes this causes a ConcurrentModificationException
* or something.
*/
public
void
testInlineCloseEvent
()
{
try
{
public
void
testInlineCloseEvent
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
RemoveClose
rc1
=
new
RemoveClose
();
RemoveClose
rc2
=
new
RemoveClose
();
...
...
@@ -222,7 +268,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con
.
close
();
con
=
pc
.
getConnection
();
con
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -233,8 +281,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* being opened for the same PooledConnection. See JDBC 2.0
* Optional Package spec section 6.3
*/
public
void
testAutomaticCloseEvent
()
{
try
{
public
void
testAutomaticCloseEvent
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
CountClose
cc
=
new
CountClose
();
pc
.
addConnectionEventListener
(
cc
);
...
...
@@ -256,7 +306,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
assertTrue
(
cc
.
getCount
()
==
2
);
assertTrue
(
cc
.
getErrorCount
()
==
0
);
pc
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -266,8 +318,10 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* you'd expect. Checks the usual case, as well as automatic
* closure when a new handle is opened on the same physical connection.
*/
public
void
testIsClosed
()
{
try
{
public
void
testIsClosed
()
{
try
{
PooledConnection
pc
=
getPooledConnection
();
Connection
con
=
pc
.
getConnection
();
assertTrue
(!
con
.
isClosed
());
...
...
@@ -280,7 +334,9 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
con2
.
close
();
assertTrue
(
con
.
isClosed
());
pc
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
fail
(
e
.
getMessage
());
}
}
...
...
@@ -288,12 +344,15 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
/**
* Helper class to remove a listener during event dispatching.
*/
private
class
RemoveClose
implements
ConnectionEventListener
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
private
class
RemoveClose
implements
ConnectionEventListener
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
((
PooledConnection
)
event
.
getSource
()).
removeConnectionEventListener
(
this
);
}
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
((
PooledConnection
)
event
.
getSource
()).
removeConnectionEventListener
(
this
);
}
}
...
...
@@ -302,25 +361,31 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
* Helper class that implements the event listener interface, and
* counts the number of events it sees.
*/
private
class
CountClose
implements
ConnectionEventListener
{
private
class
CountClose
implements
ConnectionEventListener
{
private
int
count
=
0
,
errorCount
=
0
;
public
void
connectionClosed
(
ConnectionEvent
event
)
{
public
void
connectionClosed
(
ConnectionEvent
event
)
{
count
++;
}
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
public
void
connectionErrorOccurred
(
ConnectionEvent
event
)
{
errorCount
++;
}
public
int
getCount
()
{
public
int
getCount
()
{
return
count
;
}
public
int
getErrorCount
()
{
public
int
getErrorCount
()
{
return
errorCount
;
}
public
void
clear
()
{
public
void
clear
()
{
count
=
errorCount
=
0
;
}
}
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/OptionalTestSuite.java
View file @
f37c1c48
...
...
@@ -8,14 +8,16 @@ import junit.framework.TestSuite;
* PooledConnection implementations.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
OptionalTestSuite
extends
TestSuite
{
public
class
OptionalTestSuite
extends
TestSuite
{
/**
* Gets the test suite for the entire JDBC 2.0 Optional Package
* implementation.
*/
public
static
TestSuite
suite
()
{
public
static
TestSuite
suite
()
{
TestSuite
suite
=
new
TestSuite
();
suite
.
addTestSuite
(
SimpleDataSourceTest
.
class
);
suite
.
addTestSuite
(
ConnectionPoolTest
.
class
);
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
View file @
f37c1c48
...
...
@@ -8,27 +8,34 @@ import org.postgresql.jdbc2.optional.SimpleDataSource;
* configuration logic.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
* @version $Revision: 1.
1
$
* @version $Revision: 1.
2
$
*/
public
class
SimpleDataSourceTest
extends
BaseDataSourceTest
{
public
class
SimpleDataSourceTest
extends
BaseDataSourceTest
{
/**
* Constructor required by JUnit
*/
public
SimpleDataSourceTest
(
String
name
)
{
public
SimpleDataSourceTest
(
String
name
)
{
super
(
name
);
}
/**
* Creates and configures a new SimpleDataSource.
*/
protected
void
initializeDataSource
()
{
if
(
bds
==
null
)
{
protected
void
initializeDataSource
()
{
if
(
bds
==
null
)
{
bds
=
new
SimpleDataSource
();
String
db
=
JDBC2Tests
.
getURL
();
if
(
db
.
indexOf
(
'/'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
'/'
)+
1
);
}
else
if
(
db
.
indexOf
(
':'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
':'
)+
1
);
if
(
db
.
indexOf
(
'/'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
'/'
)
+
1
);
}
else
if
(
db
.
indexOf
(
':'
)
>
-
1
)
{
db
=
db
.
substring
(
db
.
lastIndexOf
(
':'
)
+
1
);
}
bds
.
setDatabaseName
(
db
);
bds
.
setUser
(
JDBC2Tests
.
getUser
());
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
View file @
f37c1c48
src/interfaces/jdbc/org/postgresql/util/PGbytea.java
View file @
f37c1c48
...
...
@@ -5,7 +5,7 @@ import java.sql.*;
/*
* Converts to and from the postgresql bytea datatype used by the backend.
*
* $Id: PGbytea.java,v 1.
5 2002/08/16 17:51:38 barry
Exp $
* $Id: PGbytea.java,v 1.
6 2002/09/06 21:23:06 momjian
Exp $
*/
public
class
PGbytea
...
...
src/interfaces/jdbc/org/postgresql/util/PGtokenizer.java
View file @
f37c1c48
...
...
@@ -78,6 +78,7 @@ public class PGtokenizer
// Don't forget the last token ;-)
if
(
s
<
string
.
length
())
tokens
.
addElement
(
string
.
substring
(
s
));
...
...
src/interfaces/jdbc/org/postgresql/util/Serialize.java
View file @
f37c1c48
...
...
@@ -129,14 +129,16 @@ public class Serialize
try
{
conn
=
c
;
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: initializing instance for type: "
+
type
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: initializing instance for type: "
+
type
);
tableName
=
toPostgreSQL
(
type
);
className
=
type
;
ourClass
=
Class
.
forName
(
className
);
}
catch
(
ClassNotFoundException
cnfe
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
className
+
" java class not found"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
className
+
" java class not found"
);
throw
new
PSQLException
(
"postgresql.serial.noclass"
,
type
);
}
...
...
@@ -148,14 +150,16 @@ public class Serialize
if
(
rs
.
next
())
{
status
=
true
;
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
tableName
+
" table found"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
tableName
+
" table found"
);
}
rs
.
close
();
}
// This should never occur, as org.postgresql has it's own internal checks
if
(!
status
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
tableName
+
" table not found"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize: "
+
tableName
+
" table not found"
);
throw
new
PSQLException
(
"postgresql.serial.table"
,
type
);
}
// Finally cache the fields within the table
...
...
@@ -187,9 +191,11 @@ public class Serialize
{
try
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
"attempting to instantiate object of type: "
+
ourClass
.
getName
()
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
"attempting to instantiate object of type: "
+
ourClass
.
getName
()
);
Object
obj
=
ourClass
.
newInstance
();
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
"instantiated object of type: "
+
ourClass
.
getName
()
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
"instantiated object of type: "
+
ourClass
.
getName
()
);
// NB: we use java.lang.reflect here to prevent confusion with
// the org.postgresql.Field
...
...
@@ -220,7 +226,8 @@ public class Serialize
sb
.
append
(
" where oid="
);
sb
.
append
(
oid
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
sb
.
toString
());
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.fetch: "
+
sb
.
toString
());
ResultSet
rs
=
((
org
.
postgresql
.
jdbc1
.
AbstractJdbc1Connection
)
conn
).
ExecSQL
(
sb
.
toString
());
if
(
rs
!=
null
)
...
...
@@ -389,7 +396,8 @@ public class Serialize
sb
.
append
(
')'
);
}
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.store: "
+
sb
.
toString
()
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.store: "
+
sb
.
toString
()
);
ResultSet
rs
=
((
org
.
postgresql
.
jdbc1
.
AbstractJdbc1Connection
)
conn
).
ExecSQL
(
sb
.
toString
());
// fetch the OID for returning
...
...
@@ -496,13 +504,15 @@ public class Serialize
ResultSet
rs
=
((
org
.
postgresql
.
jdbc1
.
AbstractJdbc1Connection
)
con
).
ExecSQL
(
"select relname from pg_class where relname = '"
+
tableName
+
"'"
);
if
(
rs
.
next
()
)
{
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: table "
+
tableName
+
" exists, skipping"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: table "
+
tableName
+
" exists, skipping"
);
rs
.
close
();
return
;
return
;
}
// else table not found, so create it
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: table "
+
tableName
+
" not found, creating"
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: table "
+
tableName
+
" not found, creating"
);
// No entries returned, so the table doesn't exist
StringBuffer
sb
=
new
StringBuffer
(
"create table "
);
...
...
@@ -548,7 +558,8 @@ public class Serialize
sb
.
append
(
")"
);
// Now create the table
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: "
+
sb
);
if
(
Driver
.
logDebug
)
Driver
.
debug
(
"Serialize.create: "
+
sb
);
((
org
.
postgresql
.
jdbc1
.
AbstractJdbc1Connection
)
con
).
ExecSQL
(
sb
.
toString
());
}
...
...
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