- This example program is a very minimal JDBC application. JDBC is the primary API for interacting with Apache Derby. This program accomplishes the following tasks:
-
starts up the Derby engine, if necessary
+ This example program is a very minimal JDBC application. JDBC is the primary API for interacting with Apache Derby. This program:
+
+
runs in either embedded mode (the default) or as a client in a server environment, depending on the arguments passed to the program.
+
starts up the Derby engine, if running in embedded mode
+
connects to the Derby Network Server, if running in client mode
creates and connects to a database
creates a table
inserts data
@@ -60,11 +62,14 @@
selects data
drops a table
disconnects
-
shuts down Derby, if necessary
+
shuts down Derby, if running in embedded mode
- The application runs in an embedded environment. This is the simplest Derby environment. The application starts up an instance of Derby within the current JVM and shuts down the instance before it completes. No network access is involved. In an embedded environment, only one application at a time can access a database.
-
What's Included?
+ In embedded mode, the application starts up an instance of Derby within the current Java Virtual Machine and shuts down the instance before it completes. No network access is involved. Only one application can access a database at a time.
+
+
In a server environment, the application demonstrates the use of the Derby network client or the IBM DB2 JDBC Universal Driver by connecting to the Network Server and running the demo. Note that the client drivers allow multiple instances of the application to run at the same time. However, the SQL operations performed by this demo will cause failures when multiple simultaneous instances of the application are run. Use of a client driver to connect to the Network Server in this application is intended only to demonstrate this type of connection. The SimpleApp demo is not suited for simultaneous executions because it creates and drops the table on which it operates.
+
+
What's Included?
Before running this demo, you should see the following files and directories in the /demo/programs/simple directory:
@@ -81,7 +86,7 @@
- Source code for the example program that starts up Derby, creates a database, does some inserts and updates, and then shuts down Derby. Examine this file to see how the application behaves in the various environments.
+ Source code for the example program that starts up Derby, creates a database, performs some inserts and updates, and then shuts down Derby. Examine this file to see how the application behaves in the various environments.
- The directory that holds the database log for the derbyDB database.
+ The directory that holds the database transaction logs for the derbyDB database.
derbyDB\seg0 (directory)
@@ -137,27 +142,32 @@
The log file with Derby progress and error messages.
-
How to Run This Sample Application in an Embedded Environment
+
How to run this sample application in an embedded environment
-
Open a command window and change directories to the /demo/programs/simple directory.
-
If you haven't set it already on a system-wide basis, set the DERBY_INSTALL environment variable to the location of the directory where you installed the Derby software in the current command window.
-
In the command window, set CLASSPATH as follows:
+
Open a command window.
+
If you haven't set it already on a system-wide basis, set the DERBY_INSTALL environment variable to the location of the directory where you installed the Derby software in the current command window.
+
and change directories to the %DERBY_INSTALL%\demo\programs\simple directory.
+
In the command window, set the CLASSPATH as follows:
+
WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derby.jar
+UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derby.jar
+
+
Library or Directory
Path to Library or Directory
-
main Derby library for the product:
+
main Derby library:
derby.jar
-
%DERBY_INSTALL%/lib/derby.jar
+
%DERBY_INSTALL%\lib\derby.jar
-
current directory
+
current directory SimpleApp.class
-
.
+
.\
@@ -172,16 +182,16 @@
- A Note on Setting Class Path for an Embedded Environment
+ A note on setting the classpath for an embedded environment
-
Derby provides a script to help you get started setting class path in %DERBY_INSTALL%/frameworks/embedded/bin. This script is called setEmbeddedCP and comes in two flavors: one for Windows environment (this file ends with .bat) and one for UNIX environments (this file ends with .ksh). For users working in those environments, copying the commands in this file will help you get started setting the class path.
+
Derby provides a script to help you get started with setting the classpath in %DERBY_INSTALL%\frameworks\embedded\bin. This script is called setEmbeddedCP and comes in two flavors: one for Windows environment (this file ends with .bat) and one for UNIX environments (this file ends with .ksh). For users working in those environments, copying the commands in this file will help you get started setting the classpath.
-
Run Derby's utility for testing the class path for an embedded environment. You will provide the arguments embedded to indicate an embedded environment and SimpleApp.class to test for the presence of the SimpleApp class.
+
Run Derby's Sysinfo utility for testing the classpath for an embedded environment. You will provide the arguments embedded to indicate an embedded environment and SimpleApp.class to test for the presence of the SimpleApp class.
@@ -200,60 +210,325 @@
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
-
FOUND IN CLASS PATH:
+
FOUND IN classpath:
Derby embedded engine library (derby.jar)
user-specified class (SimpleApp)
-
SUCCESS: All Derby-Related classes for embedded environment found in class path.
+
SUCCESS: All Derby-Related classes for embedded environment found in classpath.
- If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the SimpleApp class to your class path, the utility would indicate as such:
+ If something is missing from your classpath environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the SimpleApp class to your classpath, the utility would indicate as such:
Testing for presence of Derby-related libraries for embedded environment.
-
FOUND IN CLASS PATH:
+
FOUND IN classpath:
Derby embedded engine library (derby.jar)
-
NOT FOUND IN CLASS PATH:
+
NOT FOUND IN classpath:
user-specified class (SimpleApp)
(SimpleApp not found.)
-
Once you have your environment set up correctly, execute the application from the same directory (/demo/programs/simple):
+
Once you have your environment set up correctly, execute the application in embedded mode from the same directory (/demo/programs/simple):
- A successful run produces the following output:
-
SimpleApp starting in embedded mode.
-
-Loaded the appropriate driver.
-
-Connected to and created database derbyDB
-
-Created table derbyDB
-
-Inserted 1956 Webster
-
-Inserted 1910 Union
-
-Updated 1956 Webster to 180 Grand
-
-Updated 180 Grand to 300 Lakeshore
-
-Verified the rows
-
-Dropped table derbyDB
-
-Closed result set and statement
-
-Committed transaction and closed connection
-
-Database shut down normally
-
-SimpleApp finished
-
-
-
Apache Derby Version 10
+
+
SimpleApp starting in embedded mode.
+Loaded the appropriate driver.
+Connected
+to and created database derbyDB
+Created table derbyDB
+
+Inserted 1956 Webster
+Inserted
+1910 Union
+Updated 1956 Webster to 180 Grand
+Updated 180 Grand to 300 Lakeshore
+Verified the rows
+Dropped table derbyDB
+
+Closed result set and statement
+Committed transaction and closed connection
+Database shut down normally
+SimpleApp
+finished
+
+
+
+
+
How to run this sample application in a server environment
+
+
You will need to set up both the client process and the server process to run the demo application as a client connecting to the Network server.
If you haven't set it already on a system-wide basis, set the DERBY_INSTALL environment variable to the location of the directory where you installed the Derby software in the current command window.
+
Change directories to the \demo\programs\simple directory.
+
In the command window for the server, set the CLASSPATH as follows:
+
+
WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbynet.jar
+UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derby.jar:${DERBY_INSTALL}/lib/derbynet.jar
+
+
+
+
+
Classpath for the process starting the Network Server
+
+
+
+
Library or Directory
+
+
+
Path to Library or Directory
+
+
+
+
+
main Derby library:
+
+
derby.jar
+
+
+
%DERBY_INSTALL%\lib\derby.jar
+
+
+
+
+
Derby Network Server:
+
+
derbynet.jar
+
+
+
%DERBY_INSTALL%\lib\derbynet.jar
+
+
+
+
+
+
+
+
+
+
A note on setting the classpath for
+ a server environment
+
+
Derby provides a script to help you get started with
+ setting the classpath in
+ %DERBY_INSTALL%\frameworks\NetworkServer\bin. This
+ script is called setNetworkServerCP and comes in
+ two flavors: one for Windows environment (this file ends with .bat) and one for UNIX environments (this file ends
+ with .ksh). For users working in those environments using the Derby Network Server,
+ copying the commands in this file will help you get started setting the
+ classpath on the server process.
+
+
+
+
+
+
Run Derby's Sysinfo utility for testing the classpath for a server environment.
+ You will provide the arguments server to indicate a server environment and SimpleApp.class to test for the presence of the SimpleApp class.
+
+ If your environment is set up correctly, the utility shows output indicating success. It looks like this:
+
+ java org.apache.derby.tools.sysinfo -cp server SimpleApp.class
+FOUND IN CLASS PATH:
+
+
+Derby Network Server library (derbynet.jar)
+
+
+ user-specified class (SimpleApp)
+
+
+ SUCCESS: All Derby related classes found in class path.
+
Server is ready to accept connections on port 1527.
+
+
+
+
Next run the SimpleApp demo in Derby client mode:
+
+
Open a command window to run the application in client mode
+
If you haven't set it already on a system-wide basis, set the DERBY_INSTALL
+ environment variable for the current command window to the location of
+ the directory where you installed the Derby software
+
Change directories to the %DERBY_INSTALL%\demo\programs\simple directory.
+
In the command window for the client, set the CLASSPATH as follows:
+
WINDOWS: set CLASSPATH=.;%DERBY_INSTALL%\lib\derbyclient.jar
+UNIX (ksh): export CLASSPATH=.:${DERBY_INSTALL}/lib/derbyclient.jar
+
+
+
Classpath for the client process when using the Derby network client
+
+
+
+
Derby network client:
+
+
derbyclient.jar
+
+
+
%DERBY_INSTALL%\lib\derbyclient.jar
+
+
+
+
+
current directory SimpleApp.class
+
+
+
.\
+
+
+
+
+
+
Run Derby's Sysinfo utility for testing the classpath for a client environment.
+ You will provide the arguments client to indicate a client environment and SimpleApp.class to test for the presence of the SimpleApp class. Note that the following assumes you have not downloaded the IBM
+ DB2 JDBC Universal Driver (see the next section for details) so the db2jcc.jar
+ is listed as NOT FOUND - this is not a problem.
+ If your environment is set up correctly, the utility shows output indicating success. It looks like this:
+
+ java org.apache.derby.tools.sysinfo -cp client SimpleApp.class
+FOUND IN CLASS PATH:
+
+ Derby Client libraries (db2jcc.jar)
+ (com.ibm.db2.jcc.DB2Driver not found.)
+
+
Now start the SimpleApp in Derby client mode:
+ java SimpleApp derbyclient
+
+ A successful run produces the following output:
+
SimpleApp starting in derbyclient mode.
+ Loaded the appropriate driver.
+ Connected to and created database derbyDB
+ Created table derbyDB
+ Inserted 1956 Webster
+ Inserted 1910 Union
+ Updated 1956 Webster to 180 Grand
+ Updated 180 Grand to 300 Lakeshore
+ Verified the rows
+ Dropped table derbyDB
+ Closed result set and statement
+ Committed transaction and closed connection
+ SimpleApp finished
+
+
Running the SimpleApp demo using the IBM DB2 JDBC Universal Driver:
+
In version 10.0 of Derby, the IBM DB2 JDBC Universal Driver was the only client driver
+that could communicate with the Derby Network Server. This driver is not licensed under the Apache License, Version 2.0 used by Apache Derby, but can be downloaded from the IBM developerWorks
+website (see: IBM
+ DB2 JDBC Universal Driver, for Apache Derby Network Server for more information). Beginning with version 10.1, the Derby network client driver is bundled with the Derby distribution and this is the recommended client driver for most applications. The DB2 Universal Driver is still supported and can be utilized with the SimpleApp demo as follows (these instructions assume you have unzipped the Universal Driver into the lib directory of DERBY_INSTALL):
+
+
Open a command window to run the application in client mode using the DB2
+ Universal Driver
+
If you haven't set it already on a system-wide basis, set the DERBY_INSTALL
+ environment variable for the current command window to the location of
+ the directory where you installed the Derby software. It is assumed that you
+ installed the IBM DB2 JDBC Universal Driver jar in the lib subdirectory
+ at this location.
+
Change directories to the %DERBY_INSTALL%\demo\programs\simple directory.
+
SimpleApp starting in jccjdbc mode.
+Loaded the appropriate driver.
+Connected to and created database derbyDB
+Created table derbyDB
+Inserted 1956 Webster
+Inserted 1910 Union
+Updated 1956 Webster to 180 Grand
+Updated 180 Grand to 300 Lakeshore
+Verified the rows
+Dropped table derbyDB
+Closed result set and statement
+Committed transaction and closed connection
+SimpleApp finished
+
+
+
+
+
+
A note on setting the classpath for a client environment (JCC)
+
+
Derby provides a script to help you get started with setting the IBM DB2
+ JDBC Universal Driver client classpath:
+ %DERBY_INSTALL%\frameworks\NetworkServer\bin. This
+ script is called setNetworkClientCP and comes in
+ two flavors: one for Windows environment (this file ends with .bat) and one for UNIX environments (this file ends
+ with .ksh). For users working in those environments using the IBM DB2 JCC Client
+ Driver Client, copying the commands in this file will help you get started
+ setting the classpath on the client process. Note to use these scripts
+ copy the jar files into the %DERBY_INSTALL%\lib directory.
+
+
+
+
+
Apache Derby Version 10.1
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/diag/ErrorMessages.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/diag/ErrorMessages.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/diag/ErrorMessages.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/diag/ErrorMessages.java Fri Jul 1 10:28:49 2005
@@ -47,12 +47,12 @@
/**
- * ErrorMessage is a VTI that shows all the SQLStates, locale-sensitive error
+ * ErrorMessage shows all the SQLStates, locale-sensitive error
* messages, and exception severities for a database.
*
- *
To use it, query it as an external virtual table:
- *
SELECT* FROM NEW ErrorMessages() AS EQ;
- *
The ErrorMessages VTI has the following columns:
+ *
To use it, query it as follows:
+ *
SELECT* FROM NEW org.apache.derby.diag.ErrorMessages() AS EQ;
+ *
The following columns will be returned:
*
SQL_STATE--VARCHAR(5) - nullable. The SQLState of the SQLException.
* (The code returned by getSQLState() in SQLException.)
*
MESSAGE--VARCHAR(32672) - nullable. The error message
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Fri Jul 1 10:28:49 2005
@@ -33,12 +33,21 @@
import java.io.ObjectOutput;
import java.io.ObjectInput;
+import java.lang.reflect.*;
+
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derby.iapi.error.PublicAPI;
+import org.apache.derby.iapi.error.StandardException;
+
/**
* This is a rudimentary connection that delegates
* EVERYTHING to Connection.
*/
public class BrokeredConnection implements Connection
{
+
+ // default for Derby
+ protected int stateHoldability = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;
protected final BrokeredConnectionControl control;
private boolean isClosed;
@@ -383,6 +392,15 @@
stateIsolationLevel = conn.getTransactionIsolation();
stateReadOnly = conn.isReadOnly();
stateAutoCommit = conn.getAutoCommit();
+ // jdk13 does not have Connection.getHoldability method and hence using
+ // reflection to cover both jdk13 and higher jdks
+ try {
+ Method sh = conn.getClass().getMethod("getHoldability", null);
+ stateHoldability = ((Integer)sh.invoke(conn, null)).intValue();
+ } catch( Exception e)
+ {
+ throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e));
+ }
}
/**
@@ -396,6 +414,8 @@
*/
public void setState(boolean complete) throws SQLException {
+ Class[] CONN_PARAM = { Integer.TYPE };
+ Object[] CONN_ARG = { new Integer(stateHoldability)};
Connection conn = getRealConnection();
@@ -403,6 +423,18 @@
conn.setTransactionIsolation(stateIsolationLevel);
conn.setReadOnly(stateReadOnly);
conn.setAutoCommit(stateAutoCommit);
+ // make the underlying connection pick my holdability state
+ // since holdability is a state of the connection handle
+ // not the underlying transaction.
+ // jdk13 does not have Connection.setHoldability method and hence using
+ // reflection to cover both jdk13 and higher jdks
+ try {
+ Method sh = conn.getClass().getMethod("setHoldability", CONN_PARAM);
+ sh.invoke(conn, CONN_ARG);
+ } catch( Exception e)
+ {
+ throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e));
+ }
}
}
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java Fri Jul 1 10:28:49 2005
@@ -32,9 +32,6 @@
*/
public class BrokeredConnection30 extends BrokeredConnection
{
-
- // default for Cloudscape
- private int stateHoldability = java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;
public BrokeredConnection30(BrokeredConnectionControl control)
{
@@ -215,19 +212,6 @@
notifyException(se);
throw se;
}
- }
- public void syncState() throws SQLException {
- super.syncState();
- // make the underlying connection pick my holdability state
- // since holdability is a state of the connection handle
- // not the underlying transaction.
- getRealConnection().setHoldability(stateHoldability);
- }
-
- public void setState(boolean complete) throws SQLException {
- super.setState(complete);
- if (complete)
- getRealConnection().setHoldability(stateHoldability);
}
public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException {
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ColumnInfo.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ColumnInfo.java Fri Jul 1 10:28:49 2005
@@ -80,13 +80,14 @@
columnTypes = new ArrayList(1);
noOfColumns = 0;
this.conn = conn;
- this.schemaName = (sName !=null ? sName.toUpperCase(java.util.Locale.ENGLISH):sName);
- this.tableName = (tName !=null ? tName.toUpperCase(java.util.Locale.ENGLISH):tName);
+
+ this.schemaName = sName;
+ this.tableName = tName;
if(insertColumnList!=null)
{
//break the comma seperated column list and initialze column info
- //eg: c2 , c1 , c3
+ //eg: C2 , C1 , C3
StringTokenizer st = new StringTokenizer(insertColumnList , ",");
while (st.hasMoreTokens())
{
@@ -152,7 +153,7 @@
ResultSet rs = dmd.getColumns(null,
schemaName,
tableName,
- (columnPattern !=null ? columnPattern.toUpperCase(java.util.Locale.ENGLISH):columnPattern));
+ columnPattern);
boolean foundTheColumn=false;
while (rs.next())
{
@@ -306,8 +307,9 @@
return sb.toString();
}
- /* returns comma seperated column Names for insert statement
- * eg: c1, c2 , c3 , c4
+ /* returns comma seperated column Names delimited by quotes for the insert
+ * statement
+ * eg: "C1", "C2" , "C3" , "C4"
*/
public String getInsertColumnNames()
{
@@ -319,7 +321,11 @@
sb.append(", ");
else
first = false;
+ // column names can be SQL reserved words, so it
+ // is necessary delimit them using quotes for insert to work correctly.
+ sb.append("\"");
sb.append(insertColumnNames.get(index));
+ sb.append("\"");
}
//there is no column info available
@@ -354,9 +360,6 @@
}
}
-
-
-
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportResultSetForObject.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportResultSetForObject.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportResultSetForObject.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/load/ExportResultSetForObject.java Fri Jul 1 10:28:49 2005
@@ -24,93 +24,104 @@
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
//uses the passed connection and table/view name to make the resultset on
//that entity. If the entity to be exported has non-sql types in it, an
//exception will be thrown
class ExportResultSetForObject {
- private Connection con;
- private String entityName;
- private String selectStatement;
- private ResultSet rs;
- private int columnCount;
- private String columnNames[];
- private String columnTypes[];
- private int columnLengths[];
-
- private Statement expStmt = null;
-
- //uses the passed connection and table/view name to make the resultset on
- //that entity.
+ private Connection con;
+ private String selectQuery;
+ private ResultSet rs;
+ private int columnCount;
+ private String columnNames[];
+ private String columnTypes[];
+ private int columnLengths[];
+
+ private Statement expStmt = null;
+ private String schemaName;
+ private String tableName;
+
+ /* set up the connection and table/view name or the select query
+ * to make the result set, whose data is exported.
+ **/
public ExportResultSetForObject(Connection con, String schemaName,
- String tableName, String selectStatement
+ String tableName, String selectQuery
)
{
this.con = con;
- if( selectStatement == null)
- this.entityName = (schemaName == null ? tableName : schemaName + "." + tableName);
- this.selectStatement = selectStatement;
+ if( selectQuery == null)
+ {
+ this.schemaName = schemaName;
+ this.tableName = tableName;
+
+ // delimit schema Name and table Name using quotes because
+ // they can be case-sensitive names or SQL reserved words. Export
+ // procedures are expected to be called with case-senisitive names.
+ // undelimited names are passed in upper case, because that is
+ // the form database stores them.
+
+ this.selectQuery = "select * from " +
+ (schemaName == null ? "\"" + tableName + "\"" :
+ "\"" + schemaName + "\"" + "." + "\"" + tableName + "\"");
+ }
+ else
+ {
+ this.selectQuery = selectQuery;
+ }
}
- public ResultSet getResultSet() throws Exception {
- rs = null;
- String queryString = getQuery();
- //execute select on passed enitity and keep it's meta data info ready
- Statement expStmt = con.createStatement();
- rs = expStmt.executeQuery(queryString);
- getMetaDataInfo();
- return rs;
- }
-
- public String getQuery(){
- if(selectStatement != null)
- return selectStatement;
- else
- {
- selectStatement = "select * from " + entityName;
- return selectStatement;
- }
- }
-
- public int getColumnCount() {
- return columnCount;
- }
-
- public String[] getColumnDefinition() {
- return columnNames;
- }
-
- public String[] getColumnTypes() {
- return columnTypes;
- }
-
- public int[] getColumnLengths() {
- return columnLengths;
- }
-
- //if the entity to be exported has non-sql types in it, an exception will be thrown
- private void getMetaDataInfo() throws Exception {
- ResultSetMetaData metaData = rs.getMetaData();
- columnCount = metaData.getColumnCount();
- int numColumns = columnCount;
- columnNames = new String[numColumns];
- columnTypes = new String[numColumns];
- columnLengths = new int[numColumns];
- for (int i=0; i 0)
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java Fri Jul 1 10:28:49 2005
@@ -251,6 +251,11 @@
if (aliasType != AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR)
return this;
+ // Don't allow creating synonyms in SESSION schema. Causes confusion if
+ // a temporary table is created later with same name.
+ if (isSessionSchema(getSchemaDescriptor().getSchemaName()))
+ throw StandardException.newException(SQLState.LANG_OPERATION_NOT_ALLOWED_ON_SESSION_SCHEMA_TABLES);
+
String targetSchema = ((SynonymAliasInfo)aliasInfo).getSynonymSchema();
String targetTable = ((SynonymAliasInfo)aliasInfo).getSynonymTable();
if (this.getObjectName().equals(targetSchema, targetTable))
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Fri Jul 1 10:28:49 2005
@@ -766,25 +766,22 @@
}
/**
- * This method will get called if the statement is referencing tables in SESSION schema.
- * We do not want to cache such statements because multiple connections can have
- * different definition of the same table name and hence compiled plan for one connection
- * may not make sense for some other connection. Because of this, remove the statement from the cache
- *
- * @exception StandardException thrown if lookup goes wrong.
- */
+ * This method will remove a statement from the statement cache.
+ * It will be called, for example, if there is an exception preparing
+ * the statement.
+ *
+ * @param statement Statement to remove
+ * @exception StandardException thrown if lookup goes wrong.
+ */
public void removeStatement(Statement statement)
throws StandardException {
if (statementCache == null)
return;
-
- synchronized (statementCache) {
-
+
Cacheable cachedItem = statementCache.findCached(statement);
if (cachedItem != null)
statementCache.remove(cachedItem);
- }
}
/**
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/sql/execute/ScrollInsensitiveResultSet.java Fri Jul 1 10:28:49 2005
@@ -232,10 +232,11 @@
}
}
- // 0 is an invalid parameter
+ // Absolute 0 is defined to be before first!
if (row == 0)
{
- throw StandardException.newException(SQLState.LANG_ZERO_INVALID_FOR_R_S_ABSOLUTE);
+ setBeforeFirstRow();
+ return null;
}
if (row > 0)
@@ -330,16 +331,15 @@
}
}
- /* Throw exception if before first or after last */
- if (beforeFirst || afterLast)
- {
- throw StandardException.newException(SQLState.LANG_NO_CURRENT_ROW_FOR_RELATIVE);
- }
-
// Return the current row for 0
if (row == 0)
{
+ if ((beforeFirst || afterLast) ||
+ (!beforeFirst && !afterLast)) {
+ return null;
+ } else {
return getRowFromHashTable(currentPosition);
+ }
}
else if (row > 0)
{
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocExtent.java Fri Jul 1 10:28:49 2005
@@ -587,6 +587,43 @@
return;
}
+ /**
+ * Undo the compress space operation.
+ *
+ * Undo of this operation doesn't really "undo" the operation, it just
+ * makes sure the data structures are ok after the undo. We are
+ * guaranteed at the point of the transaction doing the
+ * Undo of the compress space operation fixes up the bit maps to
+ * only point at pages within the new_highest_page range.
+ *
+ * Prior to logging the compress space operation all pages greater
+ * than
+ * There are only 2 possibilities at this point:
+ * 1) the truncate of pages greater than new_highest_page happened before
+ * the abort took place. W
+ * 2)
+ *
+ * @return The identifier to be used to open the conglomerate later.
+ *
+ * @param param1 param1 does this.
+ * @param param2 param2 does this.
+ *
+ * @exception StandardException Standard exception policy.
+ **/
+ protected void undoCompressPages(
+ int new_highest_page,
+ int num_pages_truncated)
+ {
+ if (new_highest_page >= 0)
+ {
+ freePages.shrink(new_highest_page + 1);
+ unFilledPages.shrink(new_highest_page + 1);
+ preAllocLength = extentLength = (new_highest_page + 1);
+ }
+
+ return;
+ }
+
protected long getExtentEnd()
{
return extentEnd;
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java Fri Jul 1 10:28:49 2005
@@ -916,6 +916,21 @@
extent.compressPages(new_highest_page, num_pages_truncated);
}
+ /**
+ * Handle undo of compress space operation.
+ **/
+ protected void undoCompressSpace(
+ LogInstant instant,
+ int new_highest_page,
+ int num_pages_truncated)
+ throws StandardException
+ {
+ logAction(instant);
+
+ extent.undoCompressPages(new_highest_page, num_pages_truncated);
+
+ }
+
public String toString()
{
if (SanityManager.DEBUG)
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/BaseContainer.java Fri Jul 1 10:28:49 2005
@@ -221,7 +221,7 @@
}
finally
{
- ntt.commitNoSync(Transaction.RELEASE_LOCKS);
+ ntt.commit();
ntt.close();
}
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/CompressSpacePageOperation.java Fri Jul 1 10:28:49 2005
@@ -182,7 +182,7 @@
"undo Page is not an allocPage");
}
- ((AllocPage)undoPage).compressSpace(
+ ((AllocPage)undoPage).undoCompressSpace(
CLRInstant, newHighestPage, num_pages_truncated);
}
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java Fri Jul 1 10:28:49 2005
@@ -1351,6 +1351,12 @@
return;
}
+ // make sure we don't execute redo recovery on any page
+ // which is getting truncated. At this point we have an exclusive
+ // table lock on the table, so after checkpoint no page change
+ // can happen between checkpoint log record and compress of space.
+ dataFactory.getRawStoreFactory().checkpoint();
+
try
{
synchronized(allocCache)
@@ -1388,6 +1394,7 @@
// reset, as pages may not exist after compress
lastUnfilledPage = ContainerHandle.INVALID_PAGE_NUMBER;
lastAllocatedPage = ContainerHandle.INVALID_PAGE_NUMBER;
+
alloc_page.compress(ntt, this);
}
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/impl/store/raw/data/PhysicalUndoOperation.java Fri Jul 1 10:28:49 2005
@@ -146,7 +146,19 @@
undoOp.undoMe(xact, this.page, instant, in);
if (SanityManager.DEBUG) {
- SanityManager.ASSERT(oldversion < this.page.getPageVersion());
+
+ if (oldversion >= this.page.getPageVersion())
+ {
+ SanityManager.THROWASSERT(
+ "oldversion = " + oldversion +
+ ";page version = " + this.page.getPageVersion() +
+ "page = " + page +
+ "; my class name is " + getClass().getName() +
+ " undoOp is " + undoOp.getClass().getName() );
+ }
+ SanityManager.ASSERT(
+ oldversion < this.page.getPageVersion());
+
if (instant != null &&
! instant.equals(this.page.getLastLogInstant()))
SanityManager.THROWASSERT(
Modified: incubator/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties?rev=208776&r1=208775&r2=208776&view=diff
==============================================================================
--- incubator/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ incubator/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties Fri Jul 1 10:28:49 2005
@@ -1095,7 +1095,7 @@
XJ077.S=Got an exception when trying to read the first byte/character of the BLOB/CLOB pattern using getBytes/getSubString.
XJ082.U=BLOB/CLOB values are not allowed as method parameters or receiver.
XJ083.U=''{0}'' not allowed because the ResultSet is not an updatable ResultSet.
-XJ084.U=Column does not correspond to a column in the base table. Can't issue {0} on this column.
+XJ084.U=Column does not correspond to a column in the base table. Cannot issue ''{0}'' on this column.
0A000.S=Feature not implemented: {0}.