⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ij.jj

📁 derby database source code.good for you.
💻 JJ
📖 第 1 页 / 共 5 页
字号:
 */ijResultDriverStatement()throws SQLException:{	Token t;	String sVal = null;}{	<DRIVER> t=<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) {			throw ijException.classNotFound(sVal);	    } catch (IllegalArgumentException e) {			throw ijException.driverNotClassName(sVal);	    } catch (IllegalAccessException e) {			throw ijException.classNotFound(sVal);	    } catch (InstantiationException e) {			throw ijException.classNotFound(sVal);	    }		return null;	}}ijResultConnectStatement()throws SQLException:{	ijResult	result;}{	<CONNECT> <TO>	( result = dynamicConnection(true) )	{		return result;	}|	<CONNECT>	( result = dynamicConnection(false) | result = staticConnection() )	{		return result;	}}/** * ConnectStatement is CONNECT 'url' [ PROTOCOL proto ] 	[ USER 	String PASSWORD String ] 	[ATTRIBUTES attributeName = value [, attributeName = value]* ]	[ AS ident ], where url is the * url for the database, i.e. jdbc:protocol:dbname etc. * Attributes are connection attributes to  * <p> * There can only be one connection at a time; if there * is already one, it is put on hold and this one takes its place. * <p> * if a driver can't be found, the current protocol will * be added at the front. * <p> * the as ident part is used for set connection.  If you don't * specify a name, we create one that is CONNECTION# for the # * of open connections that now exists. If the name duplicates, * an error results. */ijResultdynamicConnection(boolean simplifiedPath)throws SQLException:{	Token t;	Token userT = null;	Token passwordT = null;	String n = null, p = null, sVal;    String userS =  util.getSystemProperty(USER_PROPERTY);    String passwordS = util.getSystemProperty(PASSWORD_PROPERTY);	Properties connInfo = null;}{	t=<STRING>	[ <PROTOCOL> p=identifier() ] 				[ <USER> userT=<STRING> ]				[ <PASSWORD> passwordT=<STRING> ]		        [ <ATTRIBUTES> connInfo = attributeList() ]				[ <AS> n=identifier() ]	{		// t.image is a database URL		// we get the connection and salt it away		// for use with other statements.		//		// FUTURE: we could have the syntax be		// CONNECT <STRING> AS <IDENTIFIER>		// and have a SET CONNECTION string to		// re-activate a named connection.		// Or not, and wait for SQL-J to support that		// statement... although then we will have to		// figure out if we will allow that SQL-J through		// JDBC or not.		// get the value of the string		// n.b. at some point this will have to deal with ''s		if (simplifiedPath)			// url for the database W/O 'jdbc:protocol:', i.e. just a dbname			// For example,			//		CONNECT TO 'test'			// is equivalent to			// 		CONNECT TO 'jdbc:derby:test'			sVal = "jdbc:derby:" + stringValue(t.image);		else			sVal = stringValue(t.image);		// add named protocol if it was specified		if (p != null) {			String protocol = (String)namedProtocols.get(p);			if (protocol == null) { throw ijException.noSuchProtocol(p); }			sVal = protocol + sVal; 		}		if (userT != null)			userS = stringValue(userT.image);		if (passwordT != null)			passwordS = stringValue(passwordT.image);		// add protocol if no driver matches url		boolean noDriver = false;			// if we have a full URL, make sure it's loaded first			try {				if (sVal.startsWith("jdbc:"))					util.loadDriverIfKnown(sVal);			} catch (Exception e) {				// want to continue with the attempt                        }			// By default perform extra checking on the URL attributes.			// This checking does not change the processing.                        if (System.getProperty("ij.URLCheck") == null || Boolean.getBoolean("ij.URLCheck")) {                          URLCheck aCheck = new URLCheck(sVal);                        }		if (!sVal.startsWith("jdbc:") && (p == null) && (protocol != null)) {			sVal = protocol + sVal;		}		// If no ATTRIBUTES on the connection get them from the		// defaults		if (connInfo == null)			connInfo = util.updateConnInfo(userS,passwordS, 			utilInstance.getConnAttributeDefaults());		else			connInfo = util.updateConnInfo(userS,passwordS, connInfo);	   		theConnection = DriverManager.getConnection(sVal,connInfo);		return addSession( theConnection, n );	}}/**  * Handles CONNECT yadda.yadda.foo( stringArg, ... stringArg ) AS connectionName  */ijResultstaticConnection()throws SQLException:{	String			name = null;	Vector			idList;	int				idx = 0;	int				lastID = 0;	StringBuffer	buffer;	String			className;	String			methodName;	Class			classC;	Method			method;	int				argCount;	String[]		args;	Class			stringClass;	Class[]			argTypes;	ijResult		result = null;}{	idList = staticMethodName() args = staticMethodArgs() [ <AS> name = identifier() ]	{		lastID = idList.size() - 1;		buffer = new StringBuffer();		for ( ; idx < lastID; idx++ )		{			if ( idx > 0 ) { buffer.append( "." ); }			buffer.append( (String) idList.elementAt( idx ) );		}		methodName = (String) idList.elementAt( idx );		className = buffer.toString();		try {			argCount = args.length;			argTypes = new Class[ argCount ];			stringClass = Class.forName( "java.lang.String" );			for ( idx = 0; idx < argCount; idx++ ) { argTypes[ idx ] = stringClass; }			classC = Class.forName( className );			method = classC.getMethod( methodName, argTypes );			theConnection = (Connection) method.invoke( null, args );			result = addSession( theConnection, name );		} 		catch (java.lang.reflect.InvocationTargetException ite) {			Throwable t = ite.getTargetException();			if (t instanceof SQLException)				throw (SQLException) t;			throw new SQLException( t.toString() );		}		catch (Exception e) { throw new SQLException( e.toString() ); }		return result;	}}/** * SetConnectionStatement is SET CONNECTION ident * <p> * Moves to the named session, if it exists. If it doesn't * exist, remains on the current session and returns an error. */ijResultSetConnectionStatement()throws SQLException:{	String t;}{	<SET> <CONNECTION> t=identifier()	{		if (!currentConnEnv.haveSession(t)) {			throw ijException.noSuchConnection(t);		}		currentConnEnv.setCurrentSession(t);		theConnection = currentConnEnv.getConnection();		return new ijConnectionResult(theConnection);	}}/**	Shows the current connections for the current environment. */ijResultShowConnectionsStatement()throws SQLException:{}{	<SHOW> <CONNECTIONS>	{		return showConnectionsMethod(false);	}}/** * CommitStatement is simply COMMIT. * It commits the current transation. */ijResultCommitStatement()throws SQLException:{}{	<COMMIT> [ <WORK> ]	{		haveConnection();		theConnection.commit();		return null;	}}/** * RollbackStatement is simply ROLLBACK. * It undoes the current transation. */ijResultRollbackStatement()throws SQLException:{}{	<ROLLBACK> [ <WORK> ]	{		haveConnection();		theConnection.rollback();		return null;	}}/** * DisconnectStatement is simply DISCONNECT [ ALL | CURRENT | connectionName ] * it ends the specified connection(s) and * releases its statement resource. * <p> * If ALL is specified, it disconnects all available sessions * in the current environment. */ijResultDisconnectStatement()throws SQLException:{	Token a = null;	String n = null;}{	<DISCONNECT> [ ( <CURRENT> | a = <ALL> | n = identifier() ) ]	{		if ( a == null ) { 			if (n == null) {		        // only remove the current session			    haveConnection();			    // Also need to release the session object			    currentConnEnv.removeCurrentSession();			    theConnection = null;			}			else {			    if (! currentConnEnv.haveSession(n))				    throw ijException.noSuchConnection(n);				currentConnEnv.removeSession(n);			    if (currentConnEnv.getSession() == null)				    theConnection = null;			}		} else {			currentConnEnv.removeAllSessions();			theConnection = null;		}		return null;	}}ijResultExitStatement()throws SQLException:{}{	<EXIT>	{		return quit();	}|	<QUIT>	{		return quit();	}}ijResultIllegalStatementName()throws SQLException:{	Token s = null;}{	<PREPARE> <PROCEDURE> <AS> s=<STRING>	{		// "procedure" is not allowed as a statement name. this is		// because "execute procedure" is a valid Foundation2000		// command		throw ijException.illegalStatementName( "procedure" );	}}ijResultPrepareStatement()throws SQLException:{	Token t;	String i;	PreparedStatement ps;	String sVal;}{	<PREPARE> i=identifier() <AS> t=<STRING>	{		haveConnection();		sVal = stringValue(t.image);		ps = theConnection.prepareStatement(sVal);		JDBCDisplayUtil.checkNotNull(ps,"prepared statement");		currentConnEnv.getSession().addPreparedStatement(i,ps);		// all we want callers to see are the warnings.		SQLWarning w = ps.getWarnings();		ps.clearWarnings();		return new ijWarningResult(w);	}}ijResultGetCursorStatement()throws SQLException:{	haveConnection();	int scrollType = JDBC20Translation.TYPE_FORWARD_ONLY;	Token s;	Token scrolling = null;	Token withtoken = null;	int holdType = utilInstance.getHoldability(theConnection);	String c;	Statement st = null;	String sVal;	ResultSet rs = null;	SQLWarning warns;	}{	<GET> [ scrolling = <SCROLL>  scrollType = scrollType()]	[ withtoken = <WITH> holdType = holdType()] <CURSOR> c=identifier() <AS> s=<STRING>	{		sVal = stringValue(s.image);		try {			st = utilInstance.createStatement(theConnection, scrollType, holdType);			JDBCDisplayUtil.checkNotNull(st,"cursor");			st.setCursorName(c);			rs = st.executeQuery(sVal);			JDBCDisplayUtil.checkNotNull(rs,"cursor");			Session sn = currentConnEnv.getSession();			sn.addCursorStatement(c,st);			sn.addCursor(c,rs);		} catch (SQLException e) {			if (rs!=null) rs.close();			if (st!=null) st.close();			throw e;		}		// all we want callers to see are the warnings.		SQLWarning w1 = theConnection.getWarnings();		SQLWarning w2 = st.getWarnings();		SQLWarning w3 = rs.getWarnings();		theConnection.clearWarnings();		st.clearWarnings();		rs.clearWarnings();		warns = appendWarnings(w1,w2);		return new ijWarningResult(appendWarnings(warns,w3));	}}intscrollType()throws SQLException:{}{	<INSENSITIVE>	{		return JDBC20Translation.TYPE_SCROLL_INSENSITIVE;	}|	<SENSITIVE>	{		return JDBC20Translation.TYPE_SCROLL_SENSITIVE;	}}	intholdType()throws SQLException:{}{	<HOLD>	{		return JDBC30Translation.HOLD_CURSORS_OVER_COMMIT;	}|	<NOHOLD>	{		return JDBC30Translation.CLOSE_CURSORS_AT_COMMIT;	}}	ijResultAbsoluteStatement()throws SQLException:{	int row;	String c;	ResultSet rs;}{	<ABSOLUTE> row = intLiteral() c=identifier()	{		haveConnection();		// Verify that we have JDBC 2.0		Session s = currentConnEnv.getSession();		rs = (ResultSet) s.getCursor(c);		JDBCDisplayUtil.checkNotNull(rs,"cursor");		return utilInstance.absolute(rs, row);	}}ijResultRelativeStatement()throws SQLException:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -