summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/org/postgresql/util/Serialize.java
diff options
context:
space:
mode:
authorBarry Lind <barry@xythos.com>2002-06-11 02:55:16 +0000
committerBarry Lind <barry@xythos.com>2002-06-11 02:55:16 +0000
commitb465f5307f9f5506beb1edbcc0fb56eed7c29c12 (patch)
tree8b9c3b3635d22ac8e0983c28ba761ca231469c05 /src/interfaces/jdbc/org/postgresql/util/Serialize.java
parent8d1c1d40ec25424d08539cdd358cfcc437adeb63 (diff)
downloadpostgresql-b465f5307f9f5506beb1edbcc0fb56eed7c29c12.tar.gz
The patch does the following:
Allows you to set the loglevel at runtime by adding ?loglevel=X to the connection URL, where 1 = INFO and 2 = DEBUG. Automatically turns on logging by calling DriverManager.setPrintWriter(new PrintWriter(System.out)) if one is not already set. Adds a Driver.info() message that prints out the version number Adds member variables logDebug and logInfo that can be checked before making logging methods calls Adds a build number to the version number string. This build number will need to be manually incremented when we see fit. ---------------------------------------------------------------------- Modified Files: org/postgresql/Connection.java org/postgresql/Driver.java.in org/postgresql/fastpath/Fastpath.java org/postgresql/jdbc1/DatabaseMetaData.java org/postgresql/jdbc2/Connection.java org/postgresql/jdbc2/DatabaseMetaData.java org/postgresql/largeobject/LargeObjectManager.java org/postgresql/util/PSQLException.java org/postgresql/util/Serialize.java ----------------------------------------------------------------------
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/util/Serialize.java')
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/Serialize.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/util/Serialize.java b/src/interfaces/jdbc/org/postgresql/util/Serialize.java
index 59d9c03206..80d10bc541 100644
--- a/src/interfaces/jdbc/org/postgresql/util/Serialize.java
+++ b/src/interfaces/jdbc/org/postgresql/util/Serialize.java
@@ -1,5 +1,6 @@
package org.postgresql.util;
+import org.postgresql.Driver;
import java.io.*;
import java.lang.*;
import java.lang.reflect.*;
@@ -128,14 +129,14 @@ public class Serialize
try
{
conn = c;
- DriverManager.println("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)
{
- DriverManager.println("Serialize: " + className + " java class not found");
+ if (Driver.logDebug) Driver.debug("Serialize: " + className + " java class not found");
throw new PSQLException("postgresql.serial.noclass", type);
}
@@ -147,14 +148,14 @@ public class Serialize
if (rs.next())
{
status = true;
- DriverManager.println("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)
{
- DriverManager.println("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
@@ -186,9 +187,9 @@ public class Serialize
{
try
{
- DriverManager.println("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();
- DriverManager.println("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
@@ -219,7 +220,7 @@ public class Serialize
sb.append(" where oid=");
sb.append(oid);
- DriverManager.println("Serialize.fetch: " + sb.toString());
+ if (Driver.logDebug) Driver.debug("Serialize.fetch: " + sb.toString());
ResultSet rs = conn.ExecSQL(sb.toString());
if (rs != null)
@@ -388,7 +389,7 @@ public class Serialize
sb.append(')');
}
- DriverManager.println("Serialize.store: " + sb.toString() );
+ if (Driver.logDebug) Driver.debug("Serialize.store: " + sb.toString() );
org.postgresql.ResultSet rs = (org.postgresql.ResultSet) conn.ExecSQL(sb.toString());
// fetch the OID for returning
@@ -495,13 +496,13 @@ public class Serialize
ResultSet rs = con.ExecSQL("select relname from pg_class where relname = '" + tableName + "'");
if ( rs.next() )
{
- DriverManager.println("Serialize.create: table " + tableName + " exists, skipping");
+ if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " exists, skipping");
rs.close();
return;
}
// else table not found, so create it
- DriverManager.println("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 ");
@@ -547,7 +548,7 @@ public class Serialize
sb.append(")");
// Now create the table
- DriverManager.println("Serialize.create: " + sb );
+ if (Driver.logDebug) Driver.debug("Serialize.create: " + sb );
con.ExecSQL(sb.toString());
}