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

📄 main.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		  tryNetClasspath(successes, failures);		  tryClientClasspath(successes, failures);		  tryUtilsClasspath(successes, failures);		  localPW.println(successes.toString());		  if (!failures.toString().equals(crLf() + Main.getTextMessage("SIF08.E") + crLf())) {			  localPW.println(failures.toString());		  }		  else {			  localPW.println(Main.getTextMessage("SIF08.F"));		  }		  localPW.flush();	  }	private static void trySomeClasspaths(String[] args, java.io.PrintWriter localPW) throws Throwable {		boolean seenArg = false;		StringBuffer successes = new StringBuffer(Main.getTextMessage("SIF08.D")+ crLf());		StringBuffer failures = new StringBuffer(crLf() + Main.getTextMessage("SIF08.E") + crLf());		if (argumentsContain(args, EMBEDDED))		{			tryCoreClasspath(successes, failures);			seenArg =true;		}		if (argumentsContain(args,NET)) {		  tryNetClasspath(successes, failures);			seenArg =true;		}		if (argumentsContain(args,CLIENT)) {		  tryClientClasspath(successes, failures);			seenArg =true;		}		if (argumentsContain(args,TOOLS) || argumentsContain(args,"utils")) {		  tryUtilsClasspath(successes, failures);			seenArg =true;		}		String userclass = argumentMatches(args, ".class");		if (!userclass.equals("")) {			tryMyClasspath(argumentMatches(args, ".class"), Main.getTextMessage("SIF08.H", userclass), successes, failures);			seenArg =true;		}		if (seenArg)		{			localPW.println(successes.toString());			if (!failures.toString().equals(crLf() + Main.getTextMessage("SIF08.E") + crLf())) {				localPW.println(failures.toString());			}			else {				localPW.println(Main.getTextMessage("SIF08.F"));			}		}		else		{			localPW.println(Main.getTextMessage("SIF08.A", USAGESTRINGPARTA, USAGESTRINGPARTB));		}		localPW.flush();	}	private static void tryCoreClasspath(StringBuffer successes, StringBuffer failures) {		tryMyClasspath("org.apache.derby.database.Database", Main.getTextMessage("SIF08.J","derby.jar" ), successes, failures);	}	private static void tryNetClasspath(StringBuffer successes, StringBuffer failures) {		tryMyClasspath("org.apache.derby.database.Database", Main.getTextMessage("SIF08.J","derby.jar" ), successes, failures);		tryMyClasspath("org.apache.derby.drda.NetworkServerControl", Main.getTextMessage("SIF08.I", "derbynet.jar"), successes, failures);	}	private static void tryClientClasspath(StringBuffer successes, StringBuffer failures) {		tryMyClasspath("com.ibm.db2.jcc.DB2Driver", Main.getTextMessage("SIF08.L", "db2jcc.jar"), successes, failures);		tryMyClasspath("org.apache.derby.jdbc.ClientDriver", Main.getTextMessage("SIF08.L", "derbyclient.jar"), successes, failures);	}	private static void tryUtilsClasspath(StringBuffer successes, StringBuffer failures) {		tryMyClasspath("org.apache.derby.tools.ij", Main.getTextMessage("SIF08.Q", "derbytools.jar"), successes, failures);	}	private static void tryMyClasspath(String cn, String library, StringBuffer successes, StringBuffer failures) {		try {			Class.forName(cn);			successes.append(found(cn, library));		}		catch (Throwable t) {			failures.append(notFound(cn, library));		}	}	private static void tryAsResource(String cn, String library, StringBuffer successes, StringBuffer failures) {		try {			java.io.InputStream in = cn.getClass().getResourceAsStream(cn);			in.close();			successes.append(found(cn, library));		}		catch (Throwable t) {			failures.append(notFound(cn, library));		}	}	private static String found(String cn, String library) {		StringBuffer temp = new StringBuffer(crLf());		temp.append("   " + library);		temp.append(crLf());		temp.append(crLf());		return temp.toString();	}	private static String notFound(String cn, String library) {		StringBuffer temp = new StringBuffer(crLf());		temp.append("   " + library);		temp.append(crLf());		temp.append("    " + Main.getTextMessage("SIF08.U", cn));		temp.append(crLf());		temp.append(crLf());		return temp.toString();	}	private static String crLf() {		return System.getProperty("line.separator");	}	private static String lookForMainArg(String[] args, java.io.PrintWriter localPW)	{		int length=args.length;		String[] legalargs = new String[1];		legalargs[0] = EMBEDDED;		int argsfound = 0;		String whichargument="";		for (int i = 0; i < length; i++) {			for (int j=0; j < legalargs.length; j++) {				if (args[i].toUpperCase(java.util.Locale.ENGLISH).equals(legalargs[j].toUpperCase(java.util.Locale.ENGLISH))) {					argsfound++;					whichargument=legalargs[j];				}			}		}		if (argsfound > 1 || argsfound < 1) {            localPW.println(Main.getTextMessage("SIF08.A", USAGESTRINGPARTA, USAGESTRINGPARTB));			return "";		}		return whichargument;	}	private static boolean argumentsContain(String[] args, String s) {		for (int i = 0; i < args.length; i++) {			if (args[i].equalsIgnoreCase(s))				return true;		}		return false;	}	private static String argumentMatches(String[] args, String ss) {	    String userclass = "";		int length = args.length;		for (int i = 0; i < length; i++) {			if (args[i].endsWith(ss)) {				userclass = args[i].substring(0,args[i].length()-6) ;			}		}		return userclass;	}	/*	** Code related to loading info fromjar files.	*/    private static final String infoNames[] = {                                    "org/apache/derby/info/" +                                    org.apache.derby.iapi.services.info.ProductGenusNames.DBMS +                                    ".properties",                                    "org/apache/derby/info/" +                                    org.apache.derby.iapi.services.info.ProductGenusNames.TOOLS +                                    ".properties",                                    "org/apache/derby/info/" +                                    org.apache.derby.iapi.services.info.ProductGenusNames.NET +                                    ".properties",                                   "org/apache/derby/info/" +                                    org.apache.derby.iapi.services.info.ProductGenusNames.DNC +                                    ".properties"                                };    public static ZipInfoProperties[] getAllInfo(String classpath)    {        try        {			if (classpath != null) {				String cp [] = parseClasspath(classpath);				Vector v = new Vector();				for (int i = 0; i < cp.length; i++)				{					ZipInfoProperties zip = checkForInfo(cp[i]);					if (zip != null)					{						v.addElement(zip);					}				}				if (v.size() > 0)				{					ZipInfoProperties zips[] = new ZipInfoProperties[v.size()];					v.copyInto(zips);					return zips;				}			}            return loadZipFromResource();        }        catch (SecurityException se)        {            ZipInfoProperties zip[] = new ZipInfoProperties[1];            zip[0] = new ZipInfoProperties(null);            zip[0].setLocation (Main.getTextMessage ("SIF03.C"));            return zip;        }    }    /**        This method returns exactly one ZipInfoProperty in the array.        If it is able to load the sysinfo file as a resource, it returns        the ZipInfoProperty associated with that. Otherwise, the ZipInfoProperty        will be empty.     */    private static ZipInfoProperties [] loadZipFromResource()    {		java.util.ArrayList al = new java.util.ArrayList();        for (int i = 0; i < infoNames.length; i++)        {			String resource = "/".concat(infoNames[i]);            InputStream is = new Main().getClass().getResourceAsStream(resource);			if (is == null)				continue;			ZipInfoProperties ze = new ZipInfoProperties(ProductVersionHolder.getProductVersionHolderFromMyEnv(is));			ze.setLocation(resource);			al.add(ze);        }        if (al.size() == 0)        {            return null;        }        ZipInfoProperties[] zip = new ZipInfoProperties[al.size()];		al.toArray(zip);        return zip;    }    private static String [] parseClasspath(String cp)    {        StringTokenizer st = new StringTokenizer(cp, File.pathSeparator);        int count = st.countTokens();        if (count == 0)        {            return null;        }        String vals[] = new String[count];        for (int i =0; i < count; i++)        {            vals[i] = st.nextToken();        }        return vals;    }    private static ZipInfoProperties checkForInfo(String cpEntry)    {        File f = new File(cpEntry);        if ( ! f.exists())        {            return null;        }        if (f.isDirectory())        {            ZipInfoProperties zip = checkDirectory(cpEntry);            return zip;        }        if (f.isFile())        {            ZipInfoProperties zip = checkFile(cpEntry);            return zip;        }        return null;    }    private static ZipInfoProperties checkDirectory(String dirname)    {        boolean foundOne = false;        File f = null;        for (int i = 0; i < infoNames.length; i++)        {            String localSysinfo = infoNames[i].replace('/', File.separatorChar);            f = new File(dirname, localSysinfo);            if (f.exists())            {                foundOne = true;                break;            }        }        if (!foundOne || (f == null))        {            return null;        }        try        {            InputStream bis = new FileInputStream(f);            ZipInfoProperties zip = new ZipInfoProperties(ProductVersionHolder.getProductVersionHolderFromMyEnv(bis));            zip.setLocation(new File(dirname).getCanonicalPath().replace('/', File.separatorChar));            return zip;        }        catch (IOException ioe)        {            return null;        }    }    private static ZipInfoProperties checkFile(String filename)    {        // try to create a ZipFile from it	// Check to see if it's a version of db2jcc.jar and if so, report the version number. 	if (filename.indexOf("db2jcc") >= 0)	{	    Class c = null;	    Method m = null;	    Object o = null;	    Integer build = null;	    Integer major = null;            Integer minor = null;	    try 	    {                try 		{		    c = Class.forName("com.ibm.db2.jcc.DB2Driver");		    m = c.getMethod("getJCCBuildNumber", null);		    o = c.newInstance();		    build = (Integer)m.invoke(o,null);		} catch (ClassNotFoundException cnfe) {		    c = Class.forName("com.ibm.db2.jcc.DB2Version");		    m = c.getMethod("getBuildNumber", null);		    o = c.newInstance();		    build = (Integer)m.invoke(o,null);	        } 		m = c.getMethod("getMajorVersion", null);		major = (Integer)m.invoke(o,null);		m = c.getMethod("getMinorVersion", null);		minor = (Integer)m.invoke(o,null);		ProductVersionHolder jccVersion = ProductVersionHolder.getProductVersionHolder(			"IBM Corp.",			"DB2 Java Common Client",			"DRDA:jcc",			major.intValue(),			minor.intValue(),			0,			0,			build.toString(),			Boolean.FALSE);		ZipInfoProperties zip = new ZipInfoProperties(jccVersion);        zip.setLocation(new File(filename).getCanonicalPath().replace('/', File.separatorChar));		return zip;            } catch (Exception e) { return null; }	}        try        {            ZipFile zf = new ZipFile(filename);            // try to get a ZipEntry from the ZipFile            ZipEntry thisEntry = null;            for (int i =0; i < infoNames.length; i++)            {                thisEntry = zf.getEntry(infoNames[i]);                if (thisEntry != null)                {                    break;                }            }            if (thisEntry == null)            {                return null;            }            InputStream bis = zf.getInputStream(thisEntry);            if (bis == null)            {                return null;            }            ZipInfoProperties zip = new ZipInfoProperties(ProductVersionHolder.getProductVersionHolderFromMyEnv(bis));            zip.setLocation(new File(filename).getCanonicalPath().replace('/', File.separatorChar));            return zip;        }        catch (IOException ioe)        {            //guess not            return null;        }    }	/*	** Message handling	*/	private static ResourceBundle getBundle() {		try {			return ResourceBundle.getBundle("org.apache.derby.loc.sysinfoMessages");		} catch (MissingResourceException mre) {		}		return null;	}	public static String getTextMessage(String msgId) {		return getCompleteMessage(msgId, (Object[]) null);	}	public static String getTextMessage(String msgId, Object a1) {		return getCompleteMessage(msgId, new Object[] {a1});	}	public static String getTextMessage(String msgId, Object a1, Object a2) {		return getCompleteMessage(msgId, new Object[] {a1, a2});	}	public static String getTextMessage(String msgId, Object a1, Object a2, Object a3) {		return getCompleteMessage(msgId, new Object[] {a1, a2, a3});	}	public static String getTextMessage(String msgId, Object a1, Object a2, Object a3, Object a4) {		return getCompleteMessage(msgId, new Object[] {a1, a2, a3, a4});	}	/**	 */	public static String getCompleteMessage(String msgId, Object[] arguments) {		// we have a base file (sysinfoMessages.properties) so don't give us a last chance.		return org.apache.derby.iapi.services.i18n.MessageService.formatMessage(getBundle(), msgId, arguments, false);	}} // end of class Main

⌨️ 快捷键说明

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