db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1177776 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java tools/org/apache/derby/impl/tools/ij/xaHelper.java tools/org/apache/derby/impl/tools/sysinfo/Main.java
Date Fri, 30 Sep 2011 18:53:36 GMT
Author: kmarsden
Date: Fri Sep 30 18:53:36 2011
New Revision: 1177776

URL: http://svn.apache.org/viewvc?rev=1177776&view=rev
Log:
DERBY-1046 JVMInfo is duplicated in derbyclient.jar

DERBY-5431 If 10.7 or greater derbyclient.jar is in the classpath before an older release's
server jars, derby fails to boot with NoSuchFieldError for JVMInfo.JAVA_SQL_TYPES_BOOLEAN


DERBY-5439 Remove JRE / JDBC line from sysinfo

JVMInfo now lives only in derby.jar. Removing the JRE / JDBC line is only a trunk soltion.
In 10.8 we kept the duplicate code.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java?rev=1177776&r1=1177775&r2=1177776&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JDBCMBeanTest.java
Fri Sep 30 18:53:36 2011
@@ -22,12 +22,15 @@
 package org.apache.derbyTesting.functionTests.tests.management;
 
 import java.io.BufferedReader;
+import java.sql.DatabaseMetaData;
 import java.sql.Driver;
 import java.util.Hashtable;
 import javax.management.ObjectName;
 import junit.framework.Test;
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.apache.derby.iapi.services.info.JVMInfo;
 import org.apache.derbyTesting.junit.Utilities;
 
 
@@ -93,23 +96,19 @@ public class JDBCMBeanTest extends MBean
     }
     
     public void testAttributeDriverLevel() throws Exception {
-        String expected = "[Unable to get driver level from sysinfo]";
-        // Get the expected value from sysinfo
-        BufferedReader sysinfoOutput = Utilities.getSysinfoFromServer();
-        String line = null;
-        while ((line = sysinfoOutput.readLine()) != null) {
-            /* Looking for:
-             *--------- Derby Information --------
-             *JRE - JDBC: J2SE 5.0 - JDBC 3.0
-             *            ^^^^^^^^^^^^^^^^^^^
-             * (actual JRE/JDBC values may vary)*/
-            if (line.matches("^JRE - JDBC: .*")) {
-                expected = line.substring(line.indexOf(": ") + 2);
-            }
-        }
-        
-        // test the attribute value against the expected value
-        assertStringAttribute(expected,getJdbcMBeanObjectName(), "DriverLevel");
+        // get JDBC version from DatabaseMetaData for comparison
+        DatabaseMetaData dmd = getConnection().getMetaData();
+        String JDBCVersion = "" + dmd.getJDBCMajorVersion() + 
+            dmd.getJDBCMajorVersion() + "." +
+            dmd.getJDBCMinorVersion();
+        println("DatabaseMetaDataJDBCLevel = " + JDBCVersion);
+        ObjectName driverLevel = getJdbcMBeanObjectName();
+        String driverLevelString = driverLevel.toString();
+        println("MBean driverLevel  = " + driverLevelString);
+       
+        assert(driverLevelString.indexOf('?') == -1);
+        assert(driverLevelString.matches("^JRE - JDBC: " + JDBCVersion + ".*"));
+
     }
     
     /**

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java?rev=1177776&r1=1177775&r2=1177776&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java Fri Sep 30
18:53:36 2011
@@ -510,45 +510,49 @@ class xaHelper implements xaAbstractHelp
 		// if we new it directly, then it will the tools.jar file to bloat.
 		try
 		{
-			if (isJCC)
-				return (XADataSource) 
-					(Class.forName("com.ibm.db2.jcc.DB2XADataSource").newInstance());
-			else if (isNetClient){
-                            if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
-                                //running under jdk1.6 or higher 
-                                // try instantiating EmbeddedXADataSource40
-                                try {
-                                    return (XADataSource)(Class.forName(
-                                        "org.apache.derby.jdbc." +
-                                        "ClientXADataSource40").newInstance());         
                              
-                                }
-                                catch (ClassNotFoundException e) {
-                                    //probably it was not compiled with jdbc4.0
-                                    //support go ahead with EmbeddedXADataSource
-                                }
-                            }
-                            return (XADataSource) (Class.forName(
-                                    "org.apache.derby.jdbc.ClientXADataSource"
-                                    ).newInstance());
-                        }
-			else {
-                            if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
-                                //running under jdk1.6 or higher 
-                                // try instantiating EmbeddedXADataSource40
-                                try {
-                                    return (XADataSource)(Class.forName(
-                                        "org.apache.derby.jdbc." +
-                                        "EmbeddedXADataSource40").newInstance());       
                                
-                                }
-                                catch (ClassNotFoundException e) {
-                                    //probably it was not compiled with jdbc4.0
-                                    //support go ahead with EmbeddedXADataSource
-                                }
-                            }
-                            return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
-                        }
-		}
-		catch(ClassNotFoundException cnfe) {
+		    
+            if (isJCC)
+               return (XADataSource) 
+                (Class.forName("com.ibm.db2.jcc.DB2XADataSource").newInstance());
+            else if (isNetClient){
+                //running under jdk1.6 or higher 
+                // try instantiating EmbeddedXADataSource40
+                try {
+                    return (XADataSource)(Class.forName(
+                            "org.apache.derby.jdbc." +
+                    "ClientXADataSource40").newInstance());                             
          
+                }
+                catch (ClassNotFoundException e) {
+                    //probably it was not compiled with jdbc4.0
+                    //support go ahead with ClientXADataSource
+                }
+                catch (UnsupportedClassVersionError ue) { 
+                    // ClientXADataSource
+                }
+                return (XADataSource) (Class.forName(
+                        "org.apache.derby.jdbc.ClientXADataSource"
+                ).newInstance());
+            }
+            else {
+                //running under jdk1.6 or higher 
+                // try instantiating EmbeddedXADataSource40
+                try {
+                    return (XADataSource)(Class.forName(
+                            "org.apache.derby.jdbc." +
+                    "EmbeddedXADataSource40").newInstance());                           
            
+                }
+                catch (ClassNotFoundException e) {
+                    //probably it was not compiled with jdbc4.0
+                    //support go ahead with EmbeddedXADataSource
+                }
+                catch (UnsupportedClassVersionError ue) {
+                    // not jdk 16 or higher. Go ahead with
+                    // EmbeddedXADataSource
+                }
+                return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
+            }
+        }
+        catch(ClassNotFoundException cnfe) {
 			throw new ijException(LocalizedResource.getMessage("IJ_XAClass"));
 		}
 		catch (InstantiationException e) { }

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java?rev=1177776&r1=1177775&r2=1177776&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/sysinfo/Main.java Fri Sep 30
18:53:36 2011
@@ -220,8 +220,6 @@ public static void getMainInfo (java.io.
 
   private static void reportDerby (java.io.PrintWriter localAW) {
 
-	  localAW.println("JRE - JDBC: " + org.apache.derby.iapi.services.info.JVMInfo.derbyVMLevel());
-
 	  String classpath = null;
 
       try {



Mime
View raw message