Saturday, 4 April 2015



From context.xml:



<Resource

name="jdbc/testDb"

auth="Container"
type="javax.sql.DataSource"

driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306"

username="username"
password="password"
maxActive="100"
maxIdle="30"
maxWait="10000" />

...


The



auth="Container"


parameter value appears to map to a Java value of type



Enum Resource.AuthenticationType


The only documentation that I can find online references this type / value as an annotation... I do not want to annotate a class or method, but instead I'm imagining that I can store this as a property or somehow pass this value (to the JDBC driver???)... My goal is to load database connection parameters from a custom application specific source to configure any type of database connection pool on any application server (for my initial tests I'm using Tomcat 8.0 and WebLogic 12.1.3 connecting to a MySQL and Oracle database, development and production instances)


I'm unclear what this parameter maps to



type="javax.sql.DataSource"


and the



name="jdbc/testDb"


is a JNDI name reference (e.g. it does not have meaning to the JDBC / database connection) and therefore it has no baring on the exercise


My motivation is to completely avoid the J2EE context.xml, web.xml, JNDI, and every other application server's xxx.xml files to configure a "portable" JDBC connection pool -- I also do not want to invest in learning / committing to other libraries that may have some sort of mechanism / approach for doing something similar (or identical)... And for the most part it seems straight forward enough to abstract this... but the documentation around the orthogonal approach and the numerous blog / forum posts all seem to gloss over how all of the parameters map end-to-end (e.g. there's some basic concept that's either ignored my most authors / contributors - because they assume that even the most ignorant neophyte would have sufficient background to fill in what wasn't explicitly stated and / or those who are willing to post / write about this subject only have empirical / pragmatic knowledge of what worked for their projects - at this point I'm looking for something that walks through the various types of parameters that can be passed to any JDBC driver via Java / a Java API - if there are numerous variations based upon the application server's API and / or the JDBC driver I'd like to understand this too so that I can construct an abstraction that harmonizes these methods / parameters into an easy to use interface / class hierarchy...


I am not beyond borrowing from one or more open source projects that have tackled this sort of problem (but as I mentioned above - I am not interested in committing to used any of these projects for the time being)...


At this point and depending upon the complexity of the task that I've laid out for myself - I will probably post the source code to GitHub once it's in a consumable state, in case anyone else would benefit from the fruits of this labor...


No comments:

Post a Comment