📄 ij.java
字号:
currentConnEnv.getSession().addAsyncStatement(name,as); as.start(); return null; } void setConnection(ConnectionEnv connEnv, boolean multipleEnvironments) { Connection conn = connEnv.getConnection(); if (connEnv != currentConnEnv) // single connenv is common case currentConnEnv = connEnv; if (theConnection == conn) return; // not changed. if ((theConnection == null) || multipleEnvironments) { // must have switched env's (could check) theConnection = conn; } else { throw ijException.needToDisconnect(); } } /** Note the Expect Result in the output and in the stats. FIXME */ int numExpect, numPass, numFail, numUnx; private void noteExpect(boolean actual, boolean want) { numExpect++; if (actual) numPass++; else numFail++; LocalizedResource.OutputWriter().print(LocalizedResource.getMessage(actual?"IJ_Pass":"IJ_Fail")); if (actual != want) { numUnx++; LocalizedResource.OutputWriter().println(LocalizedResource.getMessage("IJ_Unx")); } else LocalizedResource.OutputWriter().println(); } private boolean getExpect() { return Boolean.getBoolean("ij.expect"); } private ijResult addSession ( Connection newConnection, String name ) throws SQLException { if (currentConnEnv.haveSession(name)) { throw ijException.alreadyHaveConnectionNamed(name); } currentConnEnv.addSession( newConnection, name ); return new ijConnectionResult( newConnection ); } private String[] sortConnectionNames() { int size = 100; int count = 0; String[] array = new String[size]; String key; Hashtable ss = currentConnEnv.getSessions(); // Calculate the number of connections in the sessions list and // build an array of all the connection names. for (Enumeration connectionNames = ss.keys(); connectionNames.hasMoreElements();) { if (count == size) { // need to expand the array size = size*2; String[] expandedArray = new String[size]; System.arraycopy(array, 0, expandedArray, 0, count); array = expandedArray; } key = (String)connectionNames.nextElement(); array[ count++ ] = key; } java.util.Arrays.sort(array, 0, count); return array; } /** This is used at the ij startup time to see if there are already some connections made and if so, show connections made so far. Following also gets executed when user types show connections command in ij. In the former case, ignore0Rows is set whereas in the later cas it's set to false. The reason for this is, at ij startup time, if there are no connections made so far, we don't want to show anything. Only if there are connections made, we show the connections. Whereas in show connection command case, we want to show the connection status either way ie if there are no connections, we say no connections. Otherwise we list all the connections made so far. */ public ijResult showConnectionsMethod(boolean ignore0Rows) throws SQLException { Hashtable ss = currentConnEnv.getSessions(); Vector v = new Vector(); SQLWarning w = null; if (ss == null || ss.size() == 0) { if (!ignore0Rows) v.addElement(LocalizedResource.getMessage("IJ_NoConneAvail")); } else { boolean haveCurrent=false; int count = 0; for (Enumeration connectionNames = ss.keys(); connectionNames.hasMoreElements(); connectionNames.nextElement()) count++; String[] array = sortConnectionNames(); for ( int ictr = 0; ictr < count; ictr++ ) { String connectionName = array[ ictr ]; Session s = (Session)ss.get(connectionName); if (s.getConnection().isClosed()) { if (currentConnEnv.getSession() != null && connectionName.equals(currentConnEnv.getSession().getName())) { currentConnEnv.removeCurrentSession(); theConnection = null; } else currentConnEnv.removeSession(connectionName); } else { StringBuffer row = new StringBuffer(); row.append(connectionName); if (currentConnEnv.getSession() != null && connectionName.equals(currentConnEnv.getSession().getName())) { row.append('*'); haveCurrent=true; } row.append(" - \u0009"); row.append(s.getConnection().getMetaData().getURL()); // save the warnings from these connections w = appendWarnings(w,s.getConnection().getWarnings()); s.getConnection().clearWarnings(); v.addElement(row.toString()); } } if (haveCurrent) v.addElement(LocalizedResource.getMessage("IJ_CurreConne")); else v.addElement(LocalizedResource.getMessage("IJ_NoCurreConne")); } return new ijVectorResult(v,w); } private Object makeXid(int xid) { return null; }//// start of BNF rules// final public ijResult ijStatement() throws ParseException, SQLException { ijResult r = null; if (jj_2_55(2)) { if (getToken(1).kind == ROLLBACK && (!(getToken(3).kind == TO || getToken(3).kind == SAVEPOINT))) { r = RollbackStatement(); } else if (jj_2_1(2)) { r = AbsoluteStatement(); } else if (jj_2_2(2)) { r = AfterLastStatement(); } else if (jj_2_3(2)) { r = AutocommitStatement(); } else if (jj_2_4(2)) { r = AsyncStatement(); } else if (jj_2_5(2)) { r = Bang(); } else if (jj_2_6(2)) { r = BeforeFirstStatement(); } else if (jj_2_7(2)) { r = CloseStatement(); } else if (jj_2_8(2)) { r = CommitStatement(); } else if (jj_2_9(2)) { r = ConnectStatement(); } else if (jj_2_10(2)) { r = DisconnectStatement(); } else if (jj_2_11(2)) { r = DriverStatement(); } else if (jj_2_12(2)) { r = ElapsedTimeStatement(); } else if (jj_2_13(2)) { r = ExecuteStatement(); } else if (jj_2_14(2)) { r = FirstStatement(); } else if (jj_2_15(2)) { r = FirstStatement(); } else if (jj_2_16(2)) { r = JBMSPreparedStatementExec(); } else if (jj_2_17(2)) { r = F2KExecuteProcedure(); } else if (jj_2_18(2)) { r = ExitStatement(); } else if (jj_2_19(2)) { r = ExpectStatement(); } else if (jj_2_20(2)) { r = GetCursorStatement(); } else if (jj_2_21(2)) { r = GetCurrentRowNumber(); } else if (jj_2_22(2)) { r = HelpStatement(); } else if (jj_2_23(2)) { r = IllegalStatementName(); } else if (jj_2_24(2)) { r = LastStatement(); } else if (jj_2_25(2)) { r = LocalizedDisplay(); } else if (jj_2_26(2)) { r = MaximumDisplayWidthStatement(); } else if (jj_2_27(2)) { r = NextStatement(); } else if (jj_2_28(2)) { r = NoHoldForConnectionStatement(); } else if (jj_2_29(2)) { r = PrepareStatement(); } else if (jj_2_30(2)) { r = PreviousStatement(); } else if (jj_2_31(2)) { r = ProtocolStatement(); } else if (jj_2_32(2)) { r = ReadOnlyStatement(); } else if (jj_2_33(2)) { r = RelativeStatement(); } else if (jj_2_34(2)) { r = RemoveStatement(); } else if (jj_2_35(2)) { r = RunStatement(); } else if (jj_2_36(2)) { r = SetConnectionStatement(); } else if (jj_2_37(2)) { r = ShowConnectionsStatement(); } else if (jj_2_38(2)) { r = WaitForStatement(); } else if (jj_2_39(2)) { r = XA_DataSourceStatement(); } else if (jj_2_40(2)) { r = XA_ConnectStatement(); } else if (jj_2_41(2)) { r = XA_CommitStatement(); } else if (jj_2_42(2)) { r = XA_DisconnectStatement(); } else if (jj_2_43(2)) { r = XA_GetConnectionStatement(); } else if (jj_2_44(2)) { r = XA_EndStatement(); } else if (jj_2_45(2)) { r = XA_ForgetStatement(); } else if (jj_2_46(2)) { r = XA_PrepareStatement(); } else if (jj_2_47(2)) { r = XA_RecoverStatement(); } else if (jj_2_48(2)) { r = XA_RollbackStatement(); } else if (jj_2_49(2)) { r = XA_StartStatement(); } else if (jj_2_50(2)) { r = DataSourceStatement(); } else if (jj_2_51(2)) { r = CP_DataSourceStatement(); } else if (jj_2_52(2)) { r = CP_ConnectStatement(); } else if (jj_2_53(2)) { r = CP_GetConnectionStatement(); } else if (jj_2_54(2)) { r = CP_DisconnectStatement(); } else { jj_consume_token(-1); throw new ParseException(); } } else { ; } jj_consume_token(0); {if (true) return r;} throw new Error("Missing return statement in function"); }/** * ProtocolStatement is PROTOCOL 'JDBC protocol' where * the protocol is used to prefix any connect request that * cannot find a driver. We will take a stab at loading * a driver as each protocol comes in -- we only know about * two. */ final public ijResult ProtocolStatement() throws ParseException, SQLException { Token t; String n = null; jj_consume_token(PROTOCOL); t = jj_consume_token(STRING); if (jj_2_56(2)) { jj_consume_token(AS); n = identifier(); } else { ; } installProtocol(n, stringValue(t.image)); {if (true) return null;} throw new Error("Missing return statement in function"); }/** * DriverStatement is DRIVER 'class' where class is the * name of a class that is a JDBC driver. It is loaded * into the DriverManager with a Class.forName call. * <p> * You can load as many drivers as you want, the idea is * to load up the appropriate one(s) for the connect(s) * that you will be issuing. */ final public ijResult DriverStatement() throws ParseException, SQLException { Token t; String sVal = null; jj_consume_token(DRIVER); t = jj_consume_token(STRING); try { // t.image is a class name; // we load the "driver" in the prototypical // manner, it will register itself with // the DriverManager. sVal = stringValue(t.image); util.loadDriver(sVal); } catch (ClassNotFoundException e) { {if (true) throw ijException.classNotFound(sVal);} } catch (IllegalArgumentException e) { {if (true) throw ijException.driverNotClassName(sVal);} } catch (IllegalAccessException e) { {if (true) throw ijException.classNotFound(sVal);} } catch (InstantiationException e) { {if (true) throw ijException.classNotFound(sVal);} } {if (true) return null;} throw new Error("Missing return statement in function"); } final public ijResult ConnectStatement() throws ParseException, SQLException { ijResult result; if (jj_2_59(2)) { jj_consume_token(CONNECT); jj_consume_token(TO); result = dynamicConnection(true); {if (true) return result;} } else if (jj_2_60(2)) { jj_consume_token(CONNECT); if (jj_2_57(2)) { result = dynamicConnection(false); } else if (jj_2_58(2)) { result = staticConnection(); } else { jj_consume_token(-1); throw new ParseException(); } {if (true) return result;} } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -