No, this is container specific. As Application Component Provider you're supposed to document the resources you need and the Application deployer and Administrator will configure them.
Up vote 3 down vote favorite 1 share g+ share fb share tw.
I know that for JBoss you need a name-ds. Xml file in the /deploy subdirectory of the appropriate instance. I don't have any experience with other J2EE containers, but im trying to stick to standards as much as possible.
Is there a standard way to define a JDBC datasource and deploy it? If possible i'd like to include my datasource inside the *. Ear file (for instance, an embedded in-memory HSQLDB datasource for demo purposes)?
If there is no standard way, will other containers at least accept the jboss way? (/deploy/*-ds. Xml) java jdbc java-ee hsqldb link|improve this question edited Nov 21 '10 at 14:18fredt3,704249 asked Feb 17 '10 at 10:36radai350314 79% accept rate.
No, this is container specific. As Application Component Provider, you're supposed to document the resources you need and the Application deployer and Administrator will configure them. If there is no standard way, will other containers at least accept the JBoss way?
No, because this is the JBoss way and thus JBoss specific. With Tomcat, you would have to use the context. Xml file.
With Jetty, jetty-env.xml. With WebSphere, you can create a so called WebSphere Enhanced EAR. With WebLogic, you can package a JDBC Module in your application.
With GlassFish, you can use the command asadmin add-resources my. Xml to add a datasource described in a XML file (example here). Etc, etc. Note that there are some projects trying to achieve this goal in a universal way like jndi-resources or Cargo.
There are also more complex solution like ControlTier or Chef. Now, in your case (as I understood you want to use an embedded database that will be bundled with your application), I don't think you should configure a datasource at the application server level. You should just package the jar of your database in your application with a standalone connection pool like c3p0 or DBCP.
This is servletcontainer specific and serveradmin responsibility. Just document your webapplication so that a datasource with name X must be created for it. That's all.
Yeah, I could do that, but I was trying to aim for the "paste-file-to-deploy-and-forget-about-it" approach – radai Feb 17 '10 at 12:46.
Sun's J2EE philosophy defines several roles in the design, development and deployment of an enterprise application. J2EE's design accommodates and reflects these separations of concerns. In particular Sun wants to separate the developer from the administrator of an application, which is a good idea.
The developer writes enterprise components in a container-agnostic way. In web. Xml, for example, you do declare your DataSources in a standard way: jdbc/myDB javax.sql.
DataSource Container This says "this database thing the application needs, make it available to me, whatever database is and whatever container you're running it in, via standard JNDI at 'jdbc/myDB' ". This is as much as the developer can do -- the rest is necessarily container specific and therefore not standardized. And then how "myDB" is actually configured is up to a different role, the administrator of the container.
So I'm repeating the correct answer above: no. But the reason is, otherwise, you'd be coding your app to a specific type of database on a specific host and port, and the point is that you shouldn't be able to do that, so there's no standard support for that on purpose.
While youre right for the general case, in my case I plan on using an in-jvm, in-memory DB, with hibernate on top (think of it as an Object cache) - something I was hoping could be done in a portable fashion – radai Feb 17 '10 at 13:18.
Not as far as I know. Will other containers at least accept the jboss way? (/deploy/*-ds.
Xml) I don't think so. At least, it's not the case of Glassfish. EDIT I suggest you try to start and stop the HSQL database from a ServletContextListener.
This then resembles what is done in unit tests, when you start and stop the HSQL database in the setUp and tearDown. You could even try to create a datasource and bind it in the JNDI at the same time -- but I don't think you need this if all you want it to have a simple-to-install demo .ear.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.