Lines 33-38
import java.sql.SQLException;
Link Here
|
33 |
import java.util.ArrayList; |
33 |
import java.util.ArrayList; |
34 |
import java.util.Properties; |
34 |
import java.util.Properties; |
35 |
|
35 |
|
|
|
36 |
import javax.naming.Context; |
37 |
import javax.naming.InitialContext; |
38 |
import javax.naming.NamingException; |
39 |
import javax.sql.DataSource; |
40 |
|
36 |
import org.apache.catalina.Container; |
41 |
import org.apache.catalina.Container; |
37 |
import org.apache.catalina.LifecycleException; |
42 |
import org.apache.catalina.LifecycleException; |
38 |
import org.apache.catalina.Loader; |
43 |
import org.apache.catalina.Loader; |
Lines 102-107
public class JDBCStore extends StoreBase {
Link Here
|
102 |
*/ |
107 |
*/ |
103 |
protected String driverName = null; |
108 |
protected String driverName = null; |
104 |
|
109 |
|
|
|
110 |
/** |
111 |
* name of the JNDI resource |
112 |
*/ |
113 |
protected String dataSourceName = null; |
114 |
|
115 |
/** |
116 |
* DataSource to use |
117 |
*/ |
118 |
protected DataSource dataSource = null; |
119 |
|
105 |
// ------------------------------------------------------------- Table & cols |
120 |
// ------------------------------------------------------------- Table & cols |
106 |
|
121 |
|
107 |
/** |
122 |
/** |
Lines 436-441
public class JDBCStore extends StoreBase {
Link Here
|
436 |
return (this.sessionLastAccessedCol); |
451 |
return (this.sessionLastAccessedCol); |
437 |
} |
452 |
} |
438 |
|
453 |
|
|
|
454 |
/** |
455 |
* Set the JNDI name of a DataSource-factory to use for db access |
456 |
* |
457 |
* @param dataSourceName The JNDI name of the DataSource-factory |
458 |
*/ |
459 |
public void setDataSourceName(String dataSourceName) { |
460 |
if (dataSourceName == null || "".equals(dataSourceName.trim())) { |
461 |
manager.getContainer() |
462 |
.getLogger() |
463 |
.warn(sm.getString(getStoreName() |
464 |
+ ".missingDataSourceName")); |
465 |
return; |
466 |
} |
467 |
this.dataSourceName = dataSourceName; |
468 |
} |
469 |
|
470 |
/** |
471 |
* Return the name of the JNDI DataSource-factory |
472 |
*/ |
473 |
public String getDataSourceName() { |
474 |
return this.dataSourceName; |
475 |
} |
476 |
|
439 |
// --------------------------------------------------------- Public Methods |
477 |
// --------------------------------------------------------- Public Methods |
440 |
|
478 |
|
441 |
/** |
479 |
/** |
Lines 866-871
public class JDBCStore extends StoreBase {
Link Here
|
866 |
if (dbConnection != null) |
904 |
if (dbConnection != null) |
867 |
return (dbConnection); |
905 |
return (dbConnection); |
868 |
|
906 |
|
|
|
907 |
if (dataSourceName != null && dataSource == null) { |
908 |
Context initCtx; |
909 |
try { |
910 |
initCtx = new InitialContext(); |
911 |
Context envCtx = (Context) initCtx.lookup("java:comp/env"); |
912 |
this.dataSource = (DataSource) envCtx.lookup(this.dataSourceName); |
913 |
} catch (NamingException e) { |
914 |
manager.getContainer() |
915 |
.getLogger() |
916 |
.error(sm.getString(getStoreName() + ".wrongDataSource", |
917 |
this.dataSourceName, e)); |
918 |
} |
919 |
} |
920 |
|
921 |
if (dataSource != null) { |
922 |
dbConnection = dataSource.getConnection(); |
923 |
return dbConnection; |
924 |
} |
925 |
|
869 |
// Instantiate our database driver if necessary |
926 |
// Instantiate our database driver if necessary |
870 |
if (driver == null) { |
927 |
if (driver == null) { |
871 |
try { |
928 |
try { |