db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1242105 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java
Date Wed, 08 Feb 2012 21:24:11 GMT
Author: rhillegas
Date: Wed Feb  8 21:24:11 2012
New Revision: 1242105

URL: http://svn.apache.org/viewvc?rev=1242105&view=rev
Log:
DERBY-5607: Use InternalDriver rather than a JDBC DataSource in order to get a connection
to the credentials db when creating a database with NATIVE authentication enabled.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java?rev=1242105&r1=1242104&r2=1242105&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/authentication/NativeAuthenticationServiceImpl.java
Wed Feb  8 21:24:11 2012
@@ -49,6 +49,7 @@ import org.apache.derby.iapi.store.acces
 import org.apache.derby.iapi.util.IdUtil;
 import org.apache.derby.iapi.util.StringUtil;
 import org.apache.derby.impl.jdbc.Util;
+import org.apache.derby.jdbc.InternalDriver;
 
 /**
  * <p>
@@ -403,27 +404,20 @@ public final class NativeAuthenticationS
             throw StandardException.newException( SQLState.BAD_NATIVE_AUTH_SPEC );
         }
         
-        String      dataSourceName = JVMInfo.J2ME ?
-            "org.apache.derby.jdbc.EmbeddedSimpleDataSource" :
-            "org.apache.derby.jdbc.EmbeddedDataSource";
-
         SQLWarning  warnings = null;
         
         try {
-            DataSource  dataSource = (DataSource) Class.forName( dataSourceName ).newInstance();
-
-            callDataSourceSetter( dataSource, "setDatabaseName", _credentialsDB );
-            callDataSourceSetter( dataSource, "setUser", userName );
-            callDataSourceSetter( dataSource, "setPassword", userPassword );
+            Properties  properties = new Properties();
+            properties.setProperty( Attribute.USERNAME_ATTR, userName );
+            properties.setProperty( Attribute.PASSWORD_ATTR, userPassword );
 
-            Connection  conn = dataSource.getConnection();
+            String  connectionURL = Attribute.PROTOCOL + _credentialsDB;
 
+            Connection  conn = InternalDriver.activeDriver().connect( connectionURL, properties
);
+            
             warnings = conn.getWarnings();
             conn.close();
         }
-        catch (ClassNotFoundException cnfe) { throw wrap( cnfe ); }
-        catch (InstantiationException ie) { throw wrap( ie ); }
-        catch (IllegalAccessException ie) { throw wrap( ie ); }
         catch (SQLException se)
         {
             String  sqlState = se.getSQLState();



Mime
View raw message