You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/08/21 18:10:43 UTC
svn commit: r433273 - in
/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij: Main.java
ij.jj mtTestCase.java utilMain.java
Author: djd
Date: Mon Aug 21 09:10:43 2006
New Revision: 433273
URL: http://svn.apache.org/viewvc?rev=433273&view=rev
Log:
DERBY-1609 (partial) Fix a security exception reading the system property ij.showErrorCode.
Add code to return an error count for runScript (still needs to be tested).
Modified:
db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java
db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java
db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java
Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java?rev=433273&r1=433272&r2=433273&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/Main.java Mon Aug 21 09:10:43 2006
@@ -216,7 +216,7 @@
out = LocalizedResource.getInstance().getNewOutput(System.out);
}
utilInstance = getutilMain(1, out);
- utilInstance.initConnections();
+ utilInstance.initFromEnvironment();
}
/**
Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj?rev=433273&r1=433272&r2=433273&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj Mon Aug 21 09:10:43 2006
@@ -128,6 +128,14 @@
ij(ijTokenManager tm, utilMain utilInstance) {
this(tm);
this.utilInstance = utilInstance;
+ }
+
+ /**
+ Initialize this parser from the environment
+ (system properties). Used when ij is being run
+ as a command line program.
+ */
+ void initFromEnvironment() {
// load all protocols specified via properties
//
Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java?rev=433273&r1=433272&r2=433273&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/mtTestCase.java Mon Aug 21 09:10:43 2006
@@ -241,7 +241,7 @@
out.println("--------------"+file+"-----------------");
utilInstance = new utilMain(1, out, ignoreErrors);
- utilInstance.initConnections();
+ utilInstance.initFromEnvironment();
utilInstance.setMtUse(true);
utilInstance.go(in, out, (java.util.Properties) null);
log.flush();
Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java?rev=433273&r1=433272&r2=433273&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Mon Aug 21 09:10:43 2006
@@ -78,6 +78,11 @@
private LocalizedOutput out = null;
private Properties connAttributeDefaults;
private Hashtable ignoreErrors;
+ /**
+ * True if to display the error code when
+ * displaying a SQLException.
+ */
+ private final boolean showErrorCode;
protected boolean isJCC; //The driver being used is JCC
@@ -136,6 +141,11 @@
ijParser = new ij(ijTokMgr, this);
this.out = out;
this.ignoreErrors = ignoreErrors;
+
+ showErrorCode =
+ Boolean.valueOf(
+ util.getSystemProperty("ij.showErrorCode")
+ ).booleanValue();
this.numConnections = numConnections;
/* 1 StatementFinder and ConnectionEnv per connection/user. */
@@ -159,8 +169,10 @@
* Initialize the connections from the environment.
*
*/
- public void initConnections()
+ public void initFromEnvironment()
{
+ ijParser.initFromEnvironment();
+
for (int ictr = 0; ictr < numConnections; ictr++)
{
try {
@@ -257,23 +269,25 @@
* @param conn
* @param in
*/
- public void goScript(Connection conn,
+ public int goScript(Connection conn,
LocalizedInput in)
{
JDBCDisplayUtil.showSelectCount = false;
connEnv[0].addSession(conn, (String) null);
fileInput = initialFileInput = !in.isStandardInput();
commandGrabber[0].ReInit(in);
- runScriptGuts();
+ return runScriptGuts();
}
/**
* Run the guts of the script. Split out to allow
* calling from the full ij and the minimal goScript.
+ * @return The number of errors seen in the script.
*
*/
- private void runScriptGuts() {
+ private int runScriptGuts() {
+ int scriptErrorCount = 0;
boolean done = false;
String command = null;
@@ -345,18 +359,23 @@
}
} catch (ParseException e) {
+ scriptErrorCount++;
if (command != null) doCatch(command);
} catch (TokenMgrError e) {
+ scriptErrorCount++;
if (command != null) doCatch(command);
} catch (SQLException e) {
+ scriptErrorCount++;
// SQL exception occurred in ij's actions; print and continue
// unless it is considered fatal.
handleSQLException(out,e);
} catch (ijException e) {
+ scriptErrorCount++;
// exception occurred in ij's actions; print and continue
out.println(langUtil.getTextMessage("IJ_IjErro0",e.getMessage()));
doTrace(e);
} catch (Throwable e) {
+ scriptErrorCount++;
out.println(langUtil.getTextMessage("IJ_JavaErro0",e.toString()));
doTrace(e);
}
@@ -364,6 +383,8 @@
/* Go to the next connection/user, if there is one */
currCE = ++currCE % connEnv.length;
}
+
+ return scriptErrorCount;
}
/**
@@ -524,7 +545,7 @@
String sqlState = null;
SQLException fatalException = null;
- if (Boolean.getBoolean("ij.showErrorCode")) {
+ if (showErrorCode) {
errorCode = langUtil.getTextMessage("IJ_Erro0",
langUtil.getNumberAsString(e.getErrorCode()));
}