📄 ij.java
字号:
execute the using statement */ if (iUsing!=null) { psUsing = (PreparedStatement) currentConnEnv.getSession().getPreparedStatement(iUsing); JDBCDisplayUtil.checkNotNull(psUsing,"prepared statement "+iUsing); } else { // (sUsing!=null) sUsingVal = stringValue(sUsing.image); psUsing = theConnection.prepareStatement(sUsingVal); JDBCDisplayUtil.checkNotNull(psUsing,"prepared statement"); warns = appendWarnings(warns, psUsing.getWarnings()); psUsing.clearWarnings(); } ResultSet rsUsing; /* If the USING statement is not a query, we will not execute the statement; the number of rows controls the execution. */ if (psUsing.execute()) { rsUsing = psUsing.getResultSet(); /* push the row of the using statement into the parameters */ ResultSetMetaData rsmdUsing = rsUsing.getMetaData(); int numCols = rsmdUsing.getColumnCount(); /* Insufficient or too many parameters will be caught at the JDBC level, and halt execution. */ boolean exec = false; /* Only do 1 next on rsUsing if autocommit is on, * since rsUsing will be closed when ps is closed. */ boolean autoCommited = false; ijMultiResult result = new ijMultiResult(ps,rsUsing,closeWhenDone);// while (! autoCommited && rsUsing.next()) {// // note the first time through// if (!exec) {// exec = true;//// // send a warning if additional results may be lost// if (theConnection.getAutoCommit()) {// // FIXME: currOut.println("IJ WARNING: Autocommit may close using result set");// autoCommited = true;// }// }// for (int c=1; c<=numCols; c++) {// if (usingObject == null)// {// ps.setObject(c,rsUsing.getObject(c),// rsmdUsing.getColumnType(c));// } // else// {// ps.setObject(c,rsUsing.getObject(c));// }// }//// /*// 4. execute the statement against those parameters// *///// ps.execute();// result.addStatementResult(ps);//// /*// 5. clear the parameters// */// ps.clearParameters();//// }// if (!exec) {// throw ijException.noUsingResults();// }//// if (! theConnection.getAutoCommit())// {// rsUsing.close();// }// // REMIND: any way to look for more rsUsing rows if autoCommit?// // perhaps just document the behavior... {if (true) return result;} } else {if (true) throw ijException.noUsingResults();} } else { // no parameters in use if (i!=null) { haveConnection(); ps = (PreparedStatement) currentConnEnv.getSession().getPreparedStatement(i); JDBCDisplayUtil.checkNotNull(ps,"prepared statement "+i); ps.execute(); {if (true) return new ijStatementResult(ps,false);} } else { // (s!=null) {if (true) return executeImmediate(stringValue(s.image));} } } throw new Error("Missing return statement in function"); }/** * Async: like execute immediate, without using, * but runs the statement in a separate thread, against * the current connection. * <p> * Syntax: * ASYNC asyncName statementSource * * statementSource is a string containing SQL-J text. */ final public ijResult AsyncStatement() throws ParseException, SQLException { Token s = null; String n = null; jj_consume_token(ASYNC); n = identifier(); s = jj_consume_token(STRING); {if (true) return executeAsync(stringValue(s.image), n);} throw new Error("Missing return statement in function"); }/** * Wait for: the second half of Async, waits for completion * if needed and then supplies the result. Only execute is done, * not row fetching. * <p> * Syntax: * WAIT FOR asyncName * * asyncName is a name used in an ASYNC statement previously */ final public ijResult WaitForStatement() throws ParseException, SQLException { Token s = null; String n = null; jj_consume_token(WAIT); jj_consume_token(FOR); n = identifier(); AsyncStatement as = currentConnEnv.getSession().getAsyncStatement(n); if (as == null) {if (true) throw ijException.noSuchAsyncStatement(n);} try { as.join(); // we wait for it to finish. } catch (InterruptedException ie) { {if (true) throw ijException.waitInterrupted(ie);} } {if (true) return as.getResult();} throw new Error("Missing return statement in function"); }/** * RemoveStatement is REMOVE identifier. It identifies * a previously prepared statement. We would prefer a DROP * syntax, but SQL-J is using that word and I want to point out * that special processing will be needed to give that parser * this parser's input for unrecognized text. */ final public ijResult RemoveStatement() throws ParseException, SQLException { String i; PreparedStatement ps; jj_consume_token(REMOVE); i = identifier(); haveConnection(); Session s = currentConnEnv.getSession(); ps = (PreparedStatement) s.getPreparedStatement(i); JDBCDisplayUtil.checkNotNull(ps,"prepared statement "+i); ps.close(); s.removePreparedStatement(i); {if (true) return null;} throw new Error("Missing return statement in function"); } final public ijResult RunStatement() throws ParseException, SQLException { Token i; Token r = null; PreparedStatement ps; jj_consume_token(RUN); if (jj_2_86(2)) { r = jj_consume_token(RESOURCE); } else { ; } i = jj_consume_token(STRING); if (utilInstance==null) {if (true) return null;} if (r == null) utilInstance.newInput(stringValue(i.image)); else utilInstance.newResourceInput(stringValue(i.image)); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * Autocommit lets you control this aspect of the connection. * REMIND: should have a general way to set all connection attributes, * this is a shortcut for immediate needs. * <p> * Syntax: * AUTOCOMMIT [ ON | OFF ] ; */ final public ijResult AutocommitStatement() throws ParseException, SQLException { Token on=null; jj_consume_token(AUTOCOMMIT); if (jj_2_87(2)) { on = jj_consume_token(ON); } else if (jj_2_88(2)) { jj_consume_token(OFF); } else { jj_consume_token(-1); throw new ParseException(); } haveConnection(); // REMIND: want to warn if unchanged? theConnection.setAutoCommit((on==null?false:true)); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * By default, holdability is set to true for Connection objects. This syntax NOHOLDFORCONNECTION lets you set it to close cursors at commit. * Syntax: * NOHOLDFORCONNECTION ; */ final public ijResult NoHoldForConnectionStatement() throws ParseException, SQLException { Token on=null; jj_consume_token(NOHOLDFORCONNECTION); haveConnection(); theConnection = utilInstance.setHoldability(theConnection, JDBC30Translation.CLOSE_CURSORS_AT_COMMIT); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * Localizeddisplay controls locale sensitive data representayion * <p> * Syntax: * LOCALIZEDDISPLAY [ ON | OFF ] ; */ final public ijResult LocalizedDisplay() throws ParseException { Token on=null; jj_consume_token(LOCALIZEDDISPLAY); if (jj_2_89(2)) { on = jj_consume_token(ON); } else if (jj_2_90(2)) { jj_consume_token(OFF); } else { jj_consume_token(-1); throw new ParseException(); } LocalizedResource.enableLocalization((on==null?false:true)); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * ReadOnly lets you control this aspect of the connection. * REMIND: should have a general way to set all connection attributes, * this is a shortcut for immediate needs. * <p> * Syntax: * READONLY [ ON | OFF ] ; */ final public ijResult ReadOnlyStatement() throws ParseException, SQLException { Token on=null; jj_consume_token(READONLY); if (jj_2_91(2)) { on = jj_consume_token(ON); } else if (jj_2_92(2)) { jj_consume_token(OFF); } else { jj_consume_token(-1); throw new ParseException(); } haveConnection(); theConnection.setReadOnly((on==null?false:true)); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * Elapsedtime on causes ij to dump out the elapsed time it takes * to run a user statement at the end of that statement. * <p> * Syntax: * ELAPSEDTIME [ ON | OFF ] ; */ final public ijResult ElapsedTimeStatement() throws ParseException { Token on=null; jj_consume_token(ELAPSEDTIME); if (jj_2_93(2)) { on = jj_consume_token(ON); } else if (jj_2_94(2)) { jj_consume_token(OFF); } else { jj_consume_token(-1); throw new ParseException(); } elapsedTime = (on != null); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * MaximumDisplayWidth EXACT_NUMERIC changes the maximum display width for * java.lang.String to the specified EXACT_NUMERIC. * This is only used by the console view. * <p> * Syntax: * MAXIMUMDISPLAYWIDTH INTEGER ; */ final public ijResult MaximumDisplayWidthStatement() throws ParseException { int maxWidth; jj_consume_token(MAXIMUMDISPLAYWIDTH); maxWidth = intValue(); JDBCDisplayUtil.setMaxDisplayWidth(maxWidth); {if (true) return null;} throw new Error("Missing return statement in function"); } final public int intValue() throws ParseException { Token t; t = jj_consume_token(INTEGER); {if (true) return Integer.parseInt(t.image);} throw new Error("Missing return statement in function"); }/** * Bang lets you issue a system command using System.exec. * <p> * Syntax: * ! 'command to issue' ; */ final public ijResult Bang() throws ParseException { Token cmd=null; jj_consume_token(BANG); cmd = jj_consume_token(STRING); ijResult result = null; try { Process p = Runtime.getRuntime().exec(stringValue(cmd.image)); LocalizedInput in = new LocalizedInput(p.getInputStream()); int c; Vector v = new Vector(); StringBuffer output = new StringBuffer(); // echo output while ((c = in.read()) != -1) { output.append((char)c); } in.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -