Re: using struts datasource from a servlet
Richard Raquepo wrote: Another option would be to configure the DS in struts but register it with a singleton (Service Locator) that can retrieve the datasource in your data access classes. maybe you can give me some link about this? tutorials maybe? any code maybe? :p As you wish: <http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html> Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using struts datasource from a servlet
> Another option would be to configure the DS in struts but register it with a > singleton (Service Locator) that can retrieve the datasource in your data > access classes. maybe you can give me some link about this? tutorials maybe? any code maybe? :p thanks a lot. - Original Message - From: "Steve Raeburn" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, June 30, 2003 3:20 PM Subject: RE: using struts datasource from a servlet > You can either pass the datasource from your servlet/action as a method > parameter or you need to register the datasource somewhere that the class > can access. > > That might be using JNDI, in which case you probably don't need to configure > your datasource in Struts but in your container. > > Another option would be to configure the DS in struts but register it with a > singleton (Service Locator) that can retrieve the datasource in your data > access classes. > > Steve > > > -Original Message- > > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > > Sent: June 29, 2003 11:54 PM > > To: Struts Users Mailing List; [EMAIL PROTECTED] > > Subject: Re: using struts datasource from a servlet > > > > > > ic... another question. > > what if it's not a servlet. just a class i made wherein i call it from one > > of my action or servlet > > but still i will need to use struts datasource. how can it be done. > > > > thanks everyone. > > > > -richard > > > > - Original Message - > > From: "Steve Raeburn" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Monday, June 30, 2003 2:34 PM > > Subject: RE: using struts datasource from a servlet > > > > > > > Struts stores the datasources as servlet context attributes. > > > > > > You can access the default datasource in your servlet using - > > > > > > (DataSource) getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); > > > > > > Take a look at the struts-config dtd for more info (particularly if you > > use > > > modules) > > > http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd > > > > > > Steve > > > > > > > -Original Message- > > > > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > > > > Sent: June 29, 2003 11:22 PM > > > > To: Struts Users Mailing List > > > > Subject: using struts datasource from a servlet > > > > > > > > > > > > can i call/use the a struts datasource in my servlet. > > > > > > > > the thing is, i have a struts app. then i created a servlet to do > > > > some specific thing. now my question is, > > > > can i use the datasource defined in my struts config file in my > > > > servlet. if so, how? example code will > > > > be very much appreciated. > > > > > > > > thanks. > > > > > > > > -richard > > > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using struts datasource from a servlet
You can either pass the datasource from your servlet/action as a method parameter or you need to register the datasource somewhere that the class can access. That might be using JNDI, in which case you probably don't need to configure your datasource in Struts but in your container. Another option would be to configure the DS in struts but register it with a singleton (Service Locator) that can retrieve the datasource in your data access classes. Steve > -Original Message- > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > Sent: June 29, 2003 11:54 PM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: Re: using struts datasource from a servlet > > > ic... another question. > what if it's not a servlet. just a class i made wherein i call it from one > of my action or servlet > but still i will need to use struts datasource. how can it be done. > > thanks everyone. > > -richard > > - Original Message - > From: "Steve Raeburn" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Sent: Monday, June 30, 2003 2:34 PM > Subject: RE: using struts datasource from a servlet > > > > Struts stores the datasources as servlet context attributes. > > > > You can access the default datasource in your servlet using - > > > > (DataSource) getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); > > > > Take a look at the struts-config dtd for more info (particularly if you > use > > modules) > > http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd > > > > Steve > > > > > -Original Message- > > > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > > > Sent: June 29, 2003 11:22 PM > > > To: Struts Users Mailing List > > > Subject: using struts datasource from a servlet > > > > > > > > > can i call/use the a struts datasource in my servlet. > > > > > > the thing is, i have a struts app. then i created a servlet to do > > > some specific thing. now my question is, > > > can i use the datasource defined in my struts config file in my > > > servlet. if so, how? example code will > > > be very much appreciated. > > > > > > thanks. > > > > > > -richard > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE : using struts datasource from a servlet
Maybe you can pass the datasource as a parameter to the class. -Message d'origine- De : Richard Raquepo [mailto:[EMAIL PROTECTED] Envoyé : lundi 30 juin 2003 8:54 À : Struts Users Mailing List; [EMAIL PROTECTED] ic... another question. what if it's not a servlet. just a class i made wherein i call it from one of my action or servlet but still i will need to use struts datasource. how can it be done. thanks everyone. -richard - Original Message - From: "Steve Raeburn" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, June 30, 2003 2:34 PM Subject: RE: using struts datasource from a servlet > Struts stores the datasources as servlet context attributes. > > You can access the default datasource in your servlet using - > > (DataSource) > getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); > > Take a look at the struts-config dtd for more info (particularly if > you use > modules) > http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd > > Steve > > > -Original Message- > > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > > Sent: June 29, 2003 11:22 PM > > To: Struts Users Mailing List > > Subject: using struts datasource from a servlet > > > > > > can i call/use the a struts datasource in my servlet. > > > > the thing is, i have a struts app. then i created a servlet to do > > some specific thing. now my question is, can i use the datasource > > defined in my struts config file in my servlet. if so, how? example > > code will be very much appreciated. > > > > thanks. > > > > -richard > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: using struts datasource from a servlet
ic... another question. what if it's not a servlet. just a class i made wherein i call it from one of my action or servlet but still i will need to use struts datasource. how can it be done. thanks everyone. -richard - Original Message - From: "Steve Raeburn" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Monday, June 30, 2003 2:34 PM Subject: RE: using struts datasource from a servlet > Struts stores the datasources as servlet context attributes. > > You can access the default datasource in your servlet using - > > (DataSource) getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); > > Take a look at the struts-config dtd for more info (particularly if you use > modules) > http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd > > Steve > > > -Original Message- > > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > > Sent: June 29, 2003 11:22 PM > > To: Struts Users Mailing List > > Subject: using struts datasource from a servlet > > > > > > can i call/use the a struts datasource in my servlet. > > > > the thing is, i have a struts app. then i created a servlet to do > > some specific thing. now my question is, > > can i use the datasource defined in my struts config file in my > > servlet. if so, how? example code will > > be very much appreciated. > > > > thanks. > > > > -richard > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: using struts datasource from a servlet
Struts stores the datasources as servlet context attributes. You can access the default datasource in your servlet using - (DataSource) getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); Take a look at the struts-config dtd for more info (particularly if you use modules) http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd Steve > -Original Message- > From: Richard Raquepo [mailto:[EMAIL PROTECTED] > Sent: June 29, 2003 11:22 PM > To: Struts Users Mailing List > Subject: using struts datasource from a servlet > > > can i call/use the a struts datasource in my servlet. > > the thing is, i have a struts app. then i created a servlet to do > some specific thing. now my question is, > can i use the datasource defined in my struts config file in my > servlet. if so, how? example code will > be very much appreciated. > > thanks. > > -richard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
using struts datasource from a servlet
can i call/use the a struts datasource in my servlet. the thing is, i have a struts app. then i created a servlet to do some specific thing. now my question is, can i use the datasource defined in my struts config file in my servlet. if so, how? example code will be very much appreciated. thanks. -richard
Re: DataSource problem
Maarten, do you declare the JNDI resource within the context tags for your webapp in server.xml, or within the global-naming-resources tags? I'm using the same setup as you with my JNDI declared in the globalnamingresources and it wouldn't work until I put a resource-link tag in the context tags. Adam Joe @ Team345 wrote: Just a guess on my part, but the connection is probably in the JNDI namespace, not the COMP namespace. To test this you can try either "java:/env" or just "/env" (sorry, can't recall which off the top of my head) where you have: "java:comp/env" As a side point, you should probably put all such logic into a session bean(s) that your action classes can call. Aside from this being a more 3-tier architecture it should allow you query your container (for instance, using the jmx-console in JBoss) to find out exactly what namespace(s) your beans are available in. hth, Joe rainer juenger wrote: Hi Maarten, join the club! There are some more guys having exactliy the same problem as you. To me your configuration looks all right. I saw some samples : driverName jdbc:mysql://localhost/test where the parameter name is not driverName but url. I tried both without luck. Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the JNDI DB Connection? Please follow the thread "Connection pooling dowsn't work for me ... Help !!" Hopefully there is someone arround giving us a tip how to get it run Good luck to all of us ;) Rainer - Original Message - From: "Maarten Roosendaal" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 14, 2002 3:42 PM Subject: DataSource problem Hi, I'm trying to create a simple DataBase app. using Struts. Right now i have a problem with getting the DataSource out of the InitialContext and i'm not sure what i'm doing wrong or maybe it has something to do with the Struts Servlet. In configured the server.xml as follows: user root password driverClassName org.gjt.mm.mysql.Driver driverName jdbc:mysql://localhost/test and my web.xml includes the following: test javax.sql.DataSource CONTAINER In an Action-class i do this: Context env = (Context) new InitialContext().lookup("java:comp/env"); DataSource ds = (DataSource) env.lookup("test"); Here the DataSource keeps ending up as NULL. When i do this: Connection con = DriverManager.getConnection(Commands.DB_TEST_URL, Commands.DB_TEST_USERNAME, ""); things are working fine but i have no idea where to look. The Context does seem to have a reference to the 'test' reference but nothing more. Does this have something to do with Struts or did i forget something? I don't want to use the struts.xml for a database-connection. One of the reasons is that i keep getting the message that it can't find the driver, while it is included in the CLASSPATH. Hope someone can help, Maarten -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource problem
Just a guess on my part, but the connection is probably in the JNDI namespace, not the COMP namespace. To test this you can try either "java:/env" or just "/env" (sorry, can't recall which off the top of my head) where you have: "java:comp/env" As a side point, you should probably put all such logic into a session bean(s) that your action classes can call. Aside from this being a more 3-tier architecture it should allow you query your container (for instance, using the jmx-console in JBoss) to find out exactly what namespace(s) your beans are available in. hth, Joe rainer juenger wrote: Hi Maarten, join the club! There are some more guys having exactliy the same problem as you. To me your configuration looks all right. I saw some samples : driverName jdbc:mysql://localhost/test where the parameter name is not driverName but url. I tried both without luck. Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the JNDI DB Connection? Please follow the thread "Connection pooling dowsn't work for me ... Help !!" Hopefully there is someone arround giving us a tip how to get it run Good luck to all of us ;) Rainer - Original Message - From: "Maarten Roosendaal" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 14, 2002 3:42 PM Subject: DataSource problem Hi, I'm trying to create a simple DataBase app. using Struts. Right now i have a problem with getting the DataSource out of the InitialContext and i'm not sure what i'm doing wrong or maybe it has something to do with the Struts Servlet. In configured the server.xml as follows: user root password driverClassName org.gjt.mm.mysql.Driver driverName jdbc:mysql://localhost/test and my web.xml includes the following: test javax.sql.DataSource CONTAINER In an Action-class i do this: Context env = (Context) new InitialContext().lookup("java:comp/env"); DataSource ds = (DataSource) env.lookup("test"); Here the DataSource keeps ending up as NULL. When i do this: Connection con = DriverManager.getConnection(Commands.DB_TEST_URL, Commands.DB_TEST_USERNAME, ""); things are working fine but i have no idea where to look. The Context does seem to have a reference to the 'test' reference but nothing more. Does this have something to do with Struts or did i forget something? I don't want to use the struts.xml for a database-connection. One of the reasons is that i keep getting the message that it can't find the driver, while it is included in the CLASSPATH. Hope someone can help, Maarten -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help on an error in my Datasource after upgrading to RC2
i have this data source in my struts-config.xml... this is not a DBCP Connection right? i doesn't work after i upgraded to RC2 the ERROR is: javax.servlet.UnavailableException: Initializing application data source DATASOURCE at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1089) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:471) at javax.servlet.GenericServlet.init(GenericServlet.java:82) at com.caucho.server.http.Application.createServlet(Application.java:3103) at com.caucho.server.http.Application.loadServlet(Application.java:3054) at com.caucho.server.http.Application.initServlets(Application.java:1914) at com.caucho.server.http.Application.init(Application.java:1827) at com.caucho.server.http.VirtualHost.init(VirtualHost.java:720) at com.caucho.server.http.ServletServer.initHosts(ServletServer.java:853) at com.caucho.server.http.ServletServer.initInternal(ServletServer.java:698) at com.caucho.server.http.ServletServer.init(ServletServer.java:509) at com.caucho.server.http.ResinServer.init(ResinServer.java:377) at com.caucho.server.http.ResinServer.main(ResinServer.java:1137) at com.caucho.server.http.HttpServer.main(HttpServer.java:103)
RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection
I use mysql and I have my jdbc2_0-stdext.jar and mysql-connector-java.jar in $TOMCAT_HOME/commons/lib and nowhere else. I face no problems. Brandon Goodin -Original Message- From: Srilatha [mailto:[EMAIL PROTECTED] Sent: Monday, June 09, 2003 12:09 AM To: Struts Users Mailing List Subject: RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection I guess u need to put the jdbc2_0-stdext.jar IN THE LIB folder and if u r using mysql put the mysql-connector-java-3.0.6-stable-bin.jar also -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 11:29 PM To: [EMAIL PROTECTED] Subject: Newbie Q: Cannot load JDBC driver class using Datasource Connection Am I missing something here? Tomcat keeps on giving me the following exception about my JDBC connection driver not being loaded when I try to establish a datasource connection to a mysql database in struts : Initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav a:529) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:38 1) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServ let.java:942) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:457) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:93 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc essorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) My struts-config.xml looks like this : Info: This driver , com.mysql.jdbc.Driver, does establish connection to this same database with no exception when I use it in a normal java class. Can someone tell me or atleast point me to where I can find further help/information. I could not find anything at http://jakarta.apache.org/struts/faqs/database.html and also in this list's archives. Thanks, robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection
I guess u need to put the jdbc2_0-stdext.jar IN THE LIB folder and if u r using mysql put the mysql-connector-java-3.0.6-stable-bin.jar also -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 11:29 PM To: [EMAIL PROTECTED] Subject: Newbie Q: Cannot load JDBC driver class using Datasource Connection Am I missing something here? Tomcat keeps on giving me the following exception about my JDBC connection driver not being loaded when I try to establish a datasource connection to a mysql database in struts : Initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav a:529) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:38 1) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServ let.java:942) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:457) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:93 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc essorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) My struts-config.xml looks like this : Info: This driver , com.mysql.jdbc.Driver, does establish connection to this same database with no exception when I use it in a normal java class. Can someone tell me or atleast point me to where I can find further help/information. I could not find anything at http://jakarta.apache.org/struts/faqs/database.html and also in this list's archives. Thanks, robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie Q: Cannot load JDBC driver class using Datasource Connection
Thanks Brandon , Dimitar, Mark It's working now : After putting the JDBC driver jar in $TOMCAT_HOME/common/lib and referencing it in Tomcat's classpath, it's working!
RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection
If you have it in the $TOMCAT_HOME/common/lib, then remove it from you web-app. It is redundant. Also, are you using the Struts Datasource config or Tomcat JNDI? Brandon Goodin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 12:57 PM To: [EMAIL PROTECTED] Subject: Re: Newbie Q: Cannot load JDBC driver class using Datasource Connection Yes, I have my JDBC driver both in my application's as well as in Tomcat's classpaths - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie Q: Cannot load JDBC driver class using Datasource Connection
Yes, I have my JDBC driver both in my application's as well as in Tomcat's classpaths
Re: Newbie Q: Cannot load JDBC driver class using Datasource Connection
I would put the JAR files of the JDBC driver in the lib folder of the application. It works in my case. dimitar - Original Message - From: "Mark Galbreath" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Saturday, June 07, 2003 2:03 PM Subject: RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection do you have your jdbc driver in your classpath? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 1:59 PM To: [EMAIL PROTECTED] Subject: Newbie Q: Cannot load JDBC driver class using Datasource Connection Am I missing something here? Tomcat keeps on giving me the following exception about my JDBC connection driver not being loaded when I try to establish a datasource connection to a mysql database in struts : Initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav a:529) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:38 1) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServ let.java:942) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:457) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:93 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc essorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) My struts-config.xml looks like this : Info: This driver , com.mysql.jdbc.Driver, does establish connection to this same database with no exception when I use it in a normal java class. Can someone tell me or atleast point me to where I can find further help/information. I could not find anything at http://jakarta.apache.org/struts/faqs/database.html and also in this list's archives. Thanks, robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Newbie Q: Cannot load JDBC driver class using Datasource Connection
do you have your jdbc driver in your classpath? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Saturday, June 07, 2003 1:59 PM To: [EMAIL PROTECTED] Subject: Newbie Q: Cannot load JDBC driver class using Datasource Connection Am I missing something here? Tomcat keeps on giving me the following exception about my JDBC connection driver not being loaded when I try to establish a datasource connection to a mysql database in struts : Initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav a:529) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:38 1) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServ let.java:942) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:457) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:93 4) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 3420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc essorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) My struts-config.xml looks like this : Info: This driver , com.mysql.jdbc.Driver, does establish connection to this same database with no exception when I use it in a normal java class. Can someone tell me or atleast point me to where I can find further help/information. I could not find anything at http://jakarta.apache.org/struts/faqs/database.html and also in this list's archives. Thanks, robert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Newbie Q: Cannot load JDBC driver class using Datasource Connection
Am I missing something here? Tomcat keeps on giving me the following exception about my JDBC connection driver not being loaded when I try to establish a datasource connection to a mysql database in struts : Initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529) at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:381) at org.apache.struts.action.ActionServlet.initApplicationDataSources(ActionServlet.java:942) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:457) at javax.servlet.GenericServlet.init(GenericServlet.java:256) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:934) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3420) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3608) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardHost.start(StandardHost.java:738) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347) at org.apache.catalina.core.StandardService.start(StandardService.java:497) at org.apache.catalina.core.StandardServer.start(StandardServer.java:2189) at org.apache.catalina.startup.Catalina.start(Catalina.java:512) at org.apache.catalina.startup.Catalina.execute(Catalina.java:400) at org.apache.catalina.startup.Catalina.process(Catalina.java:180) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc essorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203) My struts-config.xml looks like this : Info: This driver , com.mysql.jdbc.Driver, does establish connection to this same database with no exception when I use it in a normal java class. Can someone tell me or atleast point me to where I can find further help/information. I could not find anything at http://jakarta.apache.org/struts/faqs/database.html and also in this list's archives. Thanks, robert
Re: Datasource
See the following message for Craig McClanahan's take on this. http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&msgId=594323 - Jim At 10:28 PM 3/24/2003 -0500, you wrote: I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ James Watkin ACIS Software Development The Anderson School at UCLA [EMAIL PROTECTED] Voice: 1-310-825-5030 Fax: 1-310-825-4835 __ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
Yep - fandango on core! Had to throw the Big Red Switch. -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 11:00 PM Looks like Mark's brain did a core dump... -Original Message- From: Scott Barr [mailto:[EMAIL PROTECTED] Sent: Tuesday, 25 March 2003 11:50 I thought I'd stumbled onto a fishing mailing list, with those near references to carp :) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource
Can't help it number two :) now this is getting silly! I myself usually choose to set up the connections in the source code, so I can move my entire DAO layer anywhere (swing frontend for instance) with no changes at all. Really though, I don't think it would take much effort to change my connection code (which is used the Jakarta pooling stuff) to access a container managed connection. Scott Barr www.exergonic.com.au On Tue, 2003-03-25 at 14:35, Kwok Peng Tuck wrote: > I usually pick number two (if you are refering to a jndi datasource) > and leave the configuration to tomcat. So it's possible for me to move > the apps to another app server > without changing my sql code. Just have to configure the same datasource > over in the new app > server. > > > Mark Galbreath wrote: > > >I've read the literature and nothing seems definitive. Apparently we can > >declare a data source by: > > > >1. Declaring it in struts-config; > > > >2. Declaring it in the container app; > > > >3. Declaring it in the source code; > > > >4. Declaring it in the deployment descriptor; > > > >5. Declaring it in the EJB deployment descriptor. > > > >Is it just me or is this a pile of this? > > > >Mark > > > > > > > >- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
On 03/24/03 22:44:23 -0500 Mark Galbreath wrote: Well, this is getting interesting. Why does "t - i - h - s" comes out "this?" err...pile of this... (too many beers...not enough time...) err...pile of this Free Entertainment! I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. 1. AFAIK, Struts Datasources are "true" datasources. 2. The Right Way(TM) 3. The Wrong Way(TM) 4. Actually, you need to declare a reference to 2 here. Not the actual Datasource 5. See 4. That help at all? Thanks, A. -- Adam Sherman Tritus CG Inc. http://www.tritus.ca/ +1 (613) 797-6819 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource
I usually pick number two (if you are refering to a jndi datasource) and leave the configuration to tomcat. So it's possible for me to move the apps to another app server without changing my sql code. Just have to configure the same datasource over in the new app server. Mark Galbreath wrote: I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
Looks like Mark's brain did a core dump... -Original Message- From: Scott Barr [mailto:[EMAIL PROTECTED] Sent: Tuesday, 25 March 2003 11:50 To: Struts Users Mailing List Subject: Re: Datasource I thought I'd stumbled onto a fishing mailing list, with those near references to carp :) Scott Barr www.exergonic.com.au On Tue, 2003-03-25 at 14:16, Robert McIntosh wrote: > must have been writing too much self referencing code... > > Mark Galbreath wrote: > > >Well, this is getting interesting. Why does "t - i - h - s" comes out > >"this?" > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:42 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this... (too many beers...not enough time...) > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:31 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:29 PM > >To: struts > >Subject: Datasource > > > > > >I've read the literature and nothing seems definitive. Apparently we can > >declare a data source by: > > > >1. Declaring it in struts-config; > > > >2. Declaring it in the container app; > > > >3. Declaring it in the source code; > > > >4. Declaring it in the deployment descriptor; > > > >5. Declaring it in the EJB deployment descriptor. > > > >Is it just me or is this a pile of this? > > > >Mark > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
hehe! -Original Message- From: Scott Barr [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:50 PM To: Struts Users Mailing List Subject: Re: Datasource I thought I'd stumbled onto a fishing mailing list, with those near references to carp :) Scott Barr www.exergonic.com.au On Tue, 2003-03-25 at 14:16, Robert McIntosh wrote: > must have been writing too much self referencing code... > > Mark Galbreath wrote: > > >Well, this is getting interesting. Why does "t - i - h - s" comes > >out "this?" > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:42 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this... (too many beers...not enough time...) > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:31 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:29 PM > >To: struts > >Subject: Datasource > > > > > >I've read the literature and nothing seems definitive. Apparently we > >can declare a data source by: > > > >1. Declaring it in struts-config; > > > >2. Declaring it in the container app; > > > >3. Declaring it in the source code; > > > >4. Declaring it in the deployment descriptor; > > > >5. Declaring it in the EJB deployment descriptor. > > > >Is it just me or is this a pile of this? > > > >Mark > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Datasource
I thought I'd stumbled onto a fishing mailing list, with those near references to carp :) Scott Barr www.exergonic.com.au On Tue, 2003-03-25 at 14:16, Robert McIntosh wrote: > must have been writing too much self referencing code... > > Mark Galbreath wrote: > > >Well, this is getting interesting. Why does "t - i - h - s" comes out > >"this?" > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:42 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this... (too many beers...not enough time...) > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:31 PM > >To: 'Struts Users Mailing List' > >Subject: RE: Datasource > > > > > >err...pile of this > > > >-Original Message- > >From: Mark Galbreath [mailto:[EMAIL PROTECTED] > >Sent: Monday, March 24, 2003 10:29 PM > >To: struts > >Subject: Datasource > > > > > >I've read the literature and nothing seems definitive. Apparently we can > >declare a data source by: > > > >1. Declaring it in struts-config; > > > >2. Declaring it in the container app; > > > >3. Declaring it in the source code; > > > >4. Declaring it in the deployment descriptor; > > > >5. Declaring it in the EJB deployment descriptor. > > > >Is it just me or is this a pile of this? > > > >Mark > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
On Tue, 2003-03-25 at 14:14, Mark Galbreath wrote: > Well, this is getting interesting. Why does "t - i - h - s" comes out > "this?" > > -Original Message- > From: Mark Galbreath [mailto:[EMAIL PROTECTED] > Sent: Monday, March 24, 2003 10:42 PM > To: 'Struts Users Mailing List' > Subject: RE: Datasource > > > err...pile of this... (too many beers...not enough time...) > > -Original Message- > From: Mark Galbreath [mailto:[EMAIL PROTECTED] > Sent: Monday, March 24, 2003 10:31 PM > To: 'Struts Users Mailing List' > Subject: RE: Datasource > > > err...pile of this > > -Original Message- > From: Mark Galbreath [mailto:[EMAIL PROTECTED] > Sent: Monday, March 24, 2003 10:29 PM > To: struts > Subject: Datasource > > > I've read the literature and nothing seems definitive. Apparently we can > declare a data source by: > > 1. Declaring it in struts-config; > > 2. Declaring it in the container app; > > 3. Declaring it in the source code; > > 4. Declaring it in the deployment descriptor; > > 5. Declaring it in the EJB deployment descriptor. > > Is it just me or is this a pile of this? > > Mark > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >
Re: Datasource
must have been writing too much self referencing code... Mark Galbreath wrote: Well, this is getting interesting. Why does "t - i - h - s" comes out "this?" -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:42 PM To: 'Struts Users Mailing List' Subject: RE: Datasource err...pile of this... (too many beers...not enough time...) -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:31 PM To: 'Struts Users Mailing List' Subject: RE: Datasource err...pile of this -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:29 PM To: struts Subject: Datasource I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
Well, this is getting interesting. Why does "t - i - h - s" comes out "this?" -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:42 PM To: 'Struts Users Mailing List' Subject: RE: Datasource err...pile of this... (too many beers...not enough time...) -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:31 PM To: 'Struts Users Mailing List' Subject: RE: Datasource err...pile of this -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:29 PM To: struts Subject: Datasource I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
err...pile of this... (too many beers...not enough time...) -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:31 PM To: 'Struts Users Mailing List' Subject: RE: Datasource err...pile of this -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:29 PM To: struts Subject: Datasource I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Datasource
err...pile of this -Original Message- From: Mark Galbreath [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 10:29 PM To: struts Subject: Datasource I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Datasource
I've read the literature and nothing seems definitive. Apparently we can declare a data source by: 1. Declaring it in struts-config; 2. Declaring it in the container app; 3. Declaring it in the source code; 4. Declaring it in the deployment descriptor; 5. Declaring it in the EJB deployment descriptor. Is it just me or is this a pile of this? Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [newbie] Finding datasource from pool in struts-config
Action.getDataSource( httpSerlvetRequestObject , "logindb" ); or Action.getDataSource( httpServletRequest , "userdb" ); that how i do it in rc1 On Monday 24 March 2003 1:00 pm, Johan Wasserman wrote: > Hi, > How do you connect to a specific datasource pool (as configured in > strusts-config). > > I have two pools specified; > key="logindb" > key="userdb" > > ActionServlet.findDataSource is depreciated in rc 1.3 > > Thanks in advance. > Johan Wasserman - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [newbie] Finding datasource from pool in struts-config
Sorry, that's in Struts 1.1 rc3 that I found ActionServlet.findDataSource deprecated -Original Message- From: Johan Wasserman Sent: 24 March 2003 14:58 To: '[EMAIL PROTECTED]' Subject: [newbie] Finding datasource from pool in struts-config Hi, How do you connect to a specific datasource pool (as configured in strusts-config). I have two pools specified; key="logindb" key="userdb" ActionServlet.findDataSource is depreciated in rc 1.3 Thanks in advance. Johan Wasserman
[newbie] Finding datasource from pool in struts-config
Hi, How do you connect to a specific datasource pool (as configured in strusts-config). I have two pools specified; key="logindb" key="userdb" ActionServlet.findDataSource is depreciated in rc 1.3 Thanks in advance. Johan Wasserman
Re: DataSource references in Business Layer
Guido ([EMAIL PROTECTED]) wrote: > Thank you. I was searching in ActionServlet class instead of Action. > > Now the Eclipse IDE warning singal has disappear and I can sleep again :P Can you sleep for me too? I have no time for that. Dan -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Daniel Allen, <[EMAIL PROTECTED]> http://www.mojavelinux.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Chaos reigns within. Reflect, repent, and reboot. Order shall return. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource references in Business Layer
Thank you. I was searching in ActionServlet class instead of Action. Now the Eclipse IDE warning singal has disappear and I can sleep again :P On Sat, 15 Mar 2003, Dan Allen wrote: } You will inherit a method from Action called getDataSource() which I } think you should look into. There is a method in action for just } about every handler you would need, including } } getResources() } saveMessages() } saveErrors() } getDataSource() } } etc.. } } Check out the API docs for Action. } } Dan } } -- } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } Daniel Allen, <[EMAIL PROTECTED]> } http://www.mojavelinux.com/ } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } "The Linux philosophy is to laugh in face of danger. Oops. } Wrong one. 'Do it yourself' That's it" } -- Linus Torvalds } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } } - } To unsubscribe, e-mail: [EMAIL PROTECTED] } For additional commands, e-mail: [EMAIL PROTECTED] } Guido Garcia Bernardo [EMAIL PROTECTED] [EMAIL PROTECTED] "stat rosa pristina nomine, nomina nuda tenemus." http://members.ud.com/services/teams/team.htm?id=D8624419-BFB6-4772-A01A-0045631F979F - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource references in Business Layer
You can grab the datasource out of the ServletContext. Use JNDI or pass the DataSource to some ServiceFactory that your business layer can use. David From: Guido <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: DataSource references in Business Layer Date: Sat, 15 Mar 2003 17:22:20 +0100 (MET) Two simple questions. 1. I usally define all the datasources i need in struts-config.xml file. It is very easy, but how can I obtain a datasource reference in my business logic classes? I hate the idea of passing the reference to the business methods and I don't want to include all my business logic in the Action classes (that is what i am actually doing)... Maybe it is not possible and I should use JNDI or something like that instead. 2. What method should I use if ActionServlet.findDataSource(String) is now deprecated? Thank you very much, Guido. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DataSource references in Business Layer
You will inherit a method from Action called getDataSource() which I think you should look into. There is a method in action for just about every handler you would need, including getResources() saveMessages() saveErrors() getDataSource() etc.. Check out the API docs for Action. Dan -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Daniel Allen, <[EMAIL PROTECTED]> http://www.mojavelinux.com/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "The Linux philosophy is to laugh in face of danger. Oops. Wrong one. 'Do it yourself' That's it" -- Linus Torvalds - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
DataSource references in Business Layer
Two simple questions. 1. I usally define all the datasources i need in struts-config.xml file. It is very easy, but how can I obtain a datasource reference in my business logic classes? I hate the idea of passing the reference to the business methods and I don't want to include all my business logic in the Action classes (that is what i am actually doing)... Maybe it is not possible and I should use JNDI or something like that instead. 2. What method should I use if ActionServlet.findDataSource(String) is now deprecated? Thank you very much, Guido. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database datasource runtime configuration
You could create an XML configuration file and then parse it with commons-digester(filling a Java Object with the XML relevant information). I used this technique creating a class as a Struts PlugIn which parse an XML configuration file and fill the resource my application needs. Regards, Marco > -Original Message- > From: Joao Araujo [mailto:[EMAIL PROTECTED] > Sent: Saturday, March 08, 2003 3:52 AM > To: [EMAIL PROTECTED] > Subject: Database datasource runtime configuration > > > > Hi, > > > I am using the configuration of the datasource/database > inside the > struts-config.xml file. > That 's been giving me some backwards. For example I > wish to change the > hostname > after installing the whole software. I, then, need to > open the file and > change the configuration > for this. > > I wish I could put this in another file and set the > configuration at run > time. Does anyone know > how to do that? > > SAMPLE CONFIGURATION > > >type="org.apache.commons.dbcp.BasicDataSource"> > > value="oracle.jdbc.driver.OracleDriver" /> > > value="jdbc:oracle:thin:@db.db1.com:1521:" >value="system" /> >value="manager" /> >value="select 1 from dual" /> >value="DBTEST Data Source > Configuration"/> > > >value="false"/> > > > > Thanks, > > Joao, > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Database datasource runtime configuration
use database pooling dbcp from jakarta commons instead - has connection pooling and works like a charm + super setup description(despite some flaws, but no problem for us being experienced ones ;-) ). -Original Message- From: Joao Araujo [mailto:[EMAIL PROTECTED] Sent: Samstag, 08. März 2003 04:52 To: [EMAIL PROTECTED] Subject: Database datasource runtime configuration Hi, I am using the configuration of the datasource/database inside the struts-config.xml file. That 's been giving me some backwards. For example I wish to change the hostname after installing the whole software. I, then, need to open the file and change the configuration for this. I wish I could put this in another file and set the configuration at run time. Does anyone know how to do that? SAMPLE CONFIGURATION Thanks, Joao, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Database datasource runtime configuration
Hi, I am using the configuration of the datasource/database inside the struts-config.xml file. That 's been giving me some backwards. For example I wish to change the hostname after installing the whole software. I, then, need to open the file and change the configuration for this. I wish I could put this in another file and set the configuration at run time. Does anyone know how to do that? SAMPLE CONFIGURATION Thanks, Joao, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Use of Struts DataSource
>Please give me guidlines regarding use of struts datasource. http://jakarta.apache.org/struts/faqs/database.html Vlad. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Use of Struts DataSource
Hi Please give me guidlines regarding use of struts datasource. Regards Shashi
Re: Accessing struts datasource outside action servlet
You can store the DataSource in JNDI. An easier way is to configure some kind of service layer with the datasource. David From: "Dinesh Sampangi" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Subject: Accessing struts datasource outside action servlet Date: Thu, 6 Feb 2003 11:26:25 +0530 Hi All, How can i access the datasource outside the action class. suppose i need a connection in a bean/other class where i need some pre population of data from the database.. any suggestion woul be a gr8 help. rgds, Dinesh _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Accessing struts datasource outside action servlet
Hi All, How can i access the datasource outside the action class. suppose i need a connection in a bean/other class where i need some pre population of data from the database.. any suggestion woul be a gr8 help. rgds, Dinesh
Re: Design and Datasource question
subclass dispatch action. in execute method store the results from your jndi lookup in the servlet context then pass it to your data access objects which will then get connections from container pool(or your own). you only want to do the lookup once. if its ejb, you'll need to duplicate similar arrangement in that container. - Original Message - From: "Tolle Krez" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, February 05, 2003 8:42 PM Subject: Re: Design and Datasource question > I dont think it is good practice to pass datasource from Action class to your business > beans. > http://marc.theaimsgroup.com/?l=struts-user&m=104333643909577&w=2 > http://marc.theaimsgroup.com/?l=struts-user&m=104182416102397&w=2 > > I feel using JNDI to get datasource is the best choice. Others - i should have searched > the archives properly. i apologize. > > Thanks > > - Original Message - > From: "Vic Cekvenich" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, February 05, 2003 7:44 PM > Subject: Re: Design and Datasource question > > > > Some people get a connection in Action, and pass it in many ways to DAO. > > > > I get a connection in DAO (via DBCP). Ex: > > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/b asicWebLib/org > /apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2&content-type=text/vnd.view cvs-markup > > > > .V > > > > Tolle Krez wrote: > > > I am a newbie to struts and started with the struts-example application. And modified > it > > > a bit and learning.. . It looks like there are no separate model classes and all > business > > > logic exists in the Action classes itself. I am thinking of separate them. The > Datasource > > > settings are in my struts-config file and they are obtained in the Action class using > > > servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) . > > > > > > My question is, if I separate the business logic and database access away from Action > > > classes, how to I do get access to the datasource and connection pool. > > > > > > PS: I am not using EJB and only plain java classes to access the database and for > > > business logics. > > > > > > Any help is appreciated > > > > > > T > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design and Datasource question
I dont think it is good practice to pass datasource from Action class to your business beans. http://marc.theaimsgroup.com/?l=struts-user&m=104333643909577&w=2 http://marc.theaimsgroup.com/?l=struts-user&m=104182416102397&w=2 I feel using JNDI to get datasource is the best choice. Others - i should have searched the archives properly. i apologize. Thanks - Original Message - From: "Vic Cekvenich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 05, 2003 7:44 PM Subject: Re: Design and Datasource question > Some people get a connection in Action, and pass it in many ways to DAO. > > I get a connection in DAO (via DBCP). Ex: > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/basicWebLib/org /apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2&content-type=text/vnd.viewcvs-markup > > .V > > Tolle Krez wrote: > > I am a newbie to struts and started with the struts-example application. And >modified it > > a bit and learning.. . It looks like there are no separate model classes and all business > > logic exists in the Action classes itself. I am thinking of separate them. The Datasource > > settings are in my struts-config file and they are obtained in the Action class >using > > servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) . > > > > My question is, if I separate the business logic and database access away from >Action > > classes, how to I do get access to the datasource and connection pool. > > > > PS: I am not using EJB and only plain java classes to access the database and for > > business logics. > > > > Any help is appreciated > > > > T > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design and Datasource question
Some people get a connection in Action, and pass it in many ways to DAO. I get a connection in DAO (via DBCP). Ex: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/basicWebLib/org/apache/basicWebLib/DAO/BasicDAOImpl.java?rev=1.2&content-type=text/vnd.viewcvs-markup .V Tolle Krez wrote: I am a newbie to struts and started with the struts-example application. And modified it a bit and learning.. . It looks like there are no separate model classes and all business logic exists in the Action classes itself. I am thinking of separate them. The Datasource settings are in my struts-config file and they are obtained in the Action class using servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) . My question is, if I separate the business logic and database access away from Action classes, how to I do get access to the datasource and connection pool. PS: I am not using EJB and only plain java classes to access the database and for business logics. Any help is appreciated T - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Design and Datasource question
I am a newbie to struts and started with the struts-example application. And modified it a bit and learning.. . It looks like there are no separate model classes and all business logic exists in the Action classes itself. I am thinking of separate them. The Datasource settings are in my struts-config file and they are obtained in the Action class using servlet.getServletContext().getAttribute(Action.DATA_SOURCE_KEY)) . My question is, if I separate the business logic and database access away from Action classes, how to I do get access to the datasource and connection pool. PS: I am not using EJB and only plain java classes to access the database and for business logics. Any help is appreciated T - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Using Struts Datasource withaout Servlet Context
Yes, JNDI is cool ;-) I never used it, so it's time to do that ! Where did i find the value for "Context.INITIAL_CONTEXT_FACTORY" ? Fredy -Ursprüngliche Nachricht- Von: David Graham [mailto:[EMAIL PROTECTED]] Gesendet: Donnerstag, 23. Januar 2003 16:40 An: [EMAIL PROTECTED] Betreff: Re: Using Struts Datasource withaout Servlet Context JNDI David >From: "Softwareentwicklung Hauschel" <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Using Struts Datasource withaout Servlet Context >Date: Thu, 23 Jan 2003 16:37:16 +0100 > >Hey all, >i won't pass the datasource form servlet to backend, >how can i get the datasource outside a servlet ? > >Fredy > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Using Struts Datasource withaout Servlet Context
JNDI David From: "Softwareentwicklung Hauschel" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Using Struts Datasource withaout Servlet Context Date: Thu, 23 Jan 2003 16:37:16 +0100 Hey all, i won't pass the datasource form servlet to backend, how can i get the datasource outside a servlet ? Fredy -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Using Struts Datasource withaout Servlet Context
Hey all, i won't pass the datasource form servlet to backend, how can i get the datasource outside a servlet ? Fredy -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: accessing DataSource, webapp design question
On Wed, 22 Jan 2003, Charlie Toohey wrote: > Date: Wed, 22 Jan 2003 10:31:23 -0800 > From: Charlie Toohey <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: accessing DataSource, webapp design question > > This is more of a design question. I am using Struts and Tomcat, and have set > up a JNDI ref-resource to acquire a DataSource for my database, which works > fine. All of my value objects use the same database. > > The question is how to give each value object access to this DataSource. > > One option would be to lookup the JNDI contexts once, at application init, > and store the DataSource as an application scope attribute. Then whenever a > value object needs to do database work, they access this DataSource and do a > getConnection() / conn.close(). > > Another option would be to have each value object do the JNDI lookups (say, > in their constructors) and store the DataSource reference in a private field > --- then anytime they need to do database work, they use the private field > DataSource and do a getConnection() / conn.close() > > Is there any difference/advantage/disadvantage in having all value objects > using the same DataSource reference, stored at application scope, vs. all > value objects having their own reference to the DataSource ? > > Or another approach which is superior to these options ? > A third pattern is actually the recommended one -- do the lookup in your value object every time. It won't matter on Tomcat (which doesn't support these features), but it allows high-availabity servers to support transparent reconfiguration of existing connection pools, or even switching to a backup database, without making you shut down your application. Saving a reference to the connection pool you were given earlier makes all of that kind of support difficult to impossible. > Thanks, > Charlie Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: accessing DataSource, webapp design question
The value objects shouldn't know about the ServletContext so you'll need to use JNDI. JNDI doesn't tie your objects to any particular environment. My value objects don't know about the database at all. Each VO has a Mapper (or DAO) associated with it. I configure my mappers with the DataSource so they can persist the objects. This removes all persistence code from the VOs and allows pluggable persistence layers. I'm using JDBC now but could move to EJB, OJB, JDO, etc very easily. David From: Charlie Toohey <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: accessing DataSource, webapp design question Date: Wed, 22 Jan 2003 10:31:23 -0800 This is more of a design question. I am using Struts and Tomcat, and have set up a JNDI ref-resource to acquire a DataSource for my database, which works fine. All of my value objects use the same database. The question is how to give each value object access to this DataSource. One option would be to lookup the JNDI contexts once, at application init, and store the DataSource as an application scope attribute. Then whenever a value object needs to do database work, they access this DataSource and do a getConnection() / conn.close(). Another option would be to have each value object do the JNDI lookups (say, in their constructors) and store the DataSource reference in a private field --- then anytime they need to do database work, they use the private field DataSource and do a getConnection() / conn.close() Is there any difference/advantage/disadvantage in having all value objects using the same DataSource reference, stored at application scope, vs. all value objects having their own reference to the DataSource ? Or another approach which is superior to these options ? Thanks, Charlie -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
accessing DataSource, webapp design question
This is more of a design question. I am using Struts and Tomcat, and have set up a JNDI ref-resource to acquire a DataSource for my database, which works fine. All of my value objects use the same database. The question is how to give each value object access to this DataSource. One option would be to lookup the JNDI contexts once, at application init, and store the DataSource as an application scope attribute. Then whenever a value object needs to do database work, they access this DataSource and do a getConnection() / conn.close(). Another option would be to have each value object do the JNDI lookups (say, in their constructors) and store the DataSource reference in a private field --- then anytime they need to do database work, they use the private field DataSource and do a getConnection() / conn.close() Is there any difference/advantage/disadvantage in having all value objects using the same DataSource reference, stored at application scope, vs. all value objects having their own reference to the DataSource ? Or another approach which is superior to these options ? Thanks, Charlie -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: linking a struts application to a jndi resource through a datasource
On Tue, 7 Jan 2003, Mohan Radhakrishnan wrote: > Date: Tue, 7 Jan 2003 10:52:18 +0530 > From: Mohan Radhakrishnan <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: RE: linking a struts application to a jndi resource through a > dat asource > > HI, >We have done this with DBCP. Our doubt is this. If DBCP has a factory, DBCP does *not* have such a factory. It does *not* support pooled connection factory (except in the partially added code from jdbc2pool that I've never tried). > then it should also be a able to use our JTurbo pool connection factory ? > Right ? No. It only works with JDBC drivers and plain Connection instances -- DBCP provides its own pooling, so it will work with *any* JDBC driver. > Isn't it like the commons logging factory which recognizes log4j or > java.util.Logging You could always look at the sources to answer questions like this :-). > Thanks, > Mohan Craig > > -Original Message- > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 07, 2003 10:03 AM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: Re: linking a struts application to a jndi resource through a > datasource > > > > > On 6 Jan 2003, Nick Torenvliet wrote: > > > Date: 06 Jan 2003 22:46:26 -0500 > > From: Nick Torenvliet <[EMAIL PROTECTED]> > > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > > [EMAIL PROTECTED] > > To: Struts Users Mailing List <[EMAIL PROTECTED]> > > Subject: linking a struts application to a jndi resource through a > > datasource > > > > Hi, So I've got two pieces, on one side a working mysql struts data > > source example, on the other side a working tomcat 4.1 servlet.xml > > configured jndi resource linked to a mysql data base. I want to access > > the jndi from inside of struts, can I configure a data source to link to > > the jndi resource, if so should I be including any special name or key > > parameters in the datasource, or give it a special type? > > > > If you want to use JNDI-based data sources, you don't need *anything* in > struts-config.xml, and you would use the standard JNDI programming logic > to utilize it. See the following docs for more info: > > http://jakarta.apache.org/tomcat-4.1-doc/jndi-resources-howto.html > http://jakarta.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html > > Although the mechanism for configuring a JNDI data source in your > container is container-specific, the setup of your web.xml file (i.e. a > element) and the code to access it (getting the > InitialContext and so on) is portable. > > Use *either* the Struts *or* JNDI. Not both. > > Craig > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: linking a struts application to a jndi resource through a datasource
HI, We have done this with DBCP. Our doubt is this. If DBCP has a factory, then it should also be a able to use our JTurbo pool connection factory ? Right ? Isn't it like the commons logging factory which recognizes log4j or java.util.Logging Thanks, Mohan -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 10:03 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: linking a struts application to a jndi resource through a datasource On 6 Jan 2003, Nick Torenvliet wrote: > Date: 06 Jan 2003 22:46:26 -0500 > From: Nick Torenvliet <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: linking a struts application to a jndi resource through a > datasource > > Hi, So I've got two pieces, on one side a working mysql struts data > source example, on the other side a working tomcat 4.1 servlet.xml > configured jndi resource linked to a mysql data base. I want to access > the jndi from inside of struts, can I configure a data source to link to > the jndi resource, if so should I be including any special name or key > parameters in the datasource, or give it a special type? > If you want to use JNDI-based data sources, you don't need *anything* in struts-config.xml, and you would use the standard JNDI programming logic to utilize it. See the following docs for more info: http://jakarta.apache.org/tomcat-4.1-doc/jndi-resources-howto.html http://jakarta.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html Although the mechanism for configuring a JNDI data source in your container is container-specific, the setup of your web.xml file (i.e. a element) and the code to access it (getting the InitialContext and so on) is portable. Use *either* the Struts *or* JNDI. Not both. Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: linking a struts application to a jndi resource through a datasource
HI, We have done this with DBCP. Our doubt is this. If DBCP has a factory, then it should also be a able to use our JTurbo pool connection factory ? Right ? Isn't it like the commons logging factory which recognizes log4j or java.util.Logging. Thanks, Mohan -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 10:03 AM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: linking a struts application to a jndi resource through a datasource On 6 Jan 2003, Nick Torenvliet wrote: > Date: 06 Jan 2003 22:46:26 -0500 > From: Nick Torenvliet <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: linking a struts application to a jndi resource through a > datasource > > Hi, So I've got two pieces, on one side a working mysql struts data > source example, on the other side a working tomcat 4.1 servlet.xml > configured jndi resource linked to a mysql data base. I want to access > the jndi from inside of struts, can I configure a data source to link to > the jndi resource, if so should I be including any special name or key > parameters in the datasource, or give it a special type? > If you want to use JNDI-based data sources, you don't need *anything* in struts-config.xml, and you would use the standard JNDI programming logic to utilize it. See the following docs for more info: http://jakarta.apache.org/tomcat-4.1-doc/jndi-resources-howto.html http://jakarta.apache.org/tomcat-4.1-doc/jndi-datasource-examples-howto.html Although the mechanism for configuring a JNDI data source in your container is container-specific, the setup of your web.xml file (i.e. a element) and the code to access it (getting the InitialContext and so on) is portable. Use *either* the Struts *or* JNDI. Not both. Craig -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: getting a datasource in a bean
Using the element in your struts-config.xml file does *not* support the use of JNDI to retrieve it. JNDI is only used for data sources managed by your container. For Tomcat 4.1, for example, see: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html The instructions for setting up your web.xml file, and for accessing the data source in a program, are portable across any container that supports JNDI based data sources. The administrative stuff to configure them is specific to the container. To access your from an Action, you'd simply say (Struts 1.1): DataSource ds = getDataSource(request, "FIELDSTONE"); Craig On 5 Jan 2003, Nick Torenvliet wrote: > Date: 05 Jan 2003 21:34:48 -0500 > From: Nick Torenvliet <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: Re: getting a datasource in a bean > > Sounds like a plan,I've never worked with javax.naming packages before > though, I've got the following datasource > > > key="FIELDSTONE"> > > > property="autoCommit" > > value="false"/> > > > property="description" > > value="Example Data Source Configuration"/> > > > property="driverClassName" > > value="org.gjt.mm.mysql.Driver"/> > > > property="maxCount" > > value="4"/> > > > property="minCount" > > value="2"/> > > > property="password" > > value=""/> > > > property="url" > > value="jdbc:mysql://localhost:3306/wessuc"/> > > > property="username" > > value="root"/> > > > > Cound you give me some example code that uses JNDI to get a connection? > > ~/nick > > > On Sun, 2003-01-05 at 17:46, Max Kremer wrote: > > You can just look up the JNDI datasource in your bean. > > - Original Message - > > From: "Nick Torenvliet" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Sunday, January 05, 2003 4:51 PM > > Subject: getting a datasource in a bean > > > > > > > Hi, Just as in the examples on the struts site I've succesfully > > > configured a mysql datasource and had it print the results of queries > > > from out of an action class. I am using struts 1.1-b2. > > > > > > I want to replace my current dbpooling(I wrote last year)with the struts > > > datasource and dbcp, I am having one problem though. I can't get a > > > connection in my beans to the database because I have no access to the > > > getDataSource(request,key) method. Since my pooling methods were hard > > > wired I just went in to the database by passing a database name to the > > > methods. > > > > > > The stock answer is to pass a connection to the bean, but that means > > > I'll be rewriting a lot of code. > > > > > > How can I access the datasource from a bean? > > > > > > ~/nick > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > - > > > > > > > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: getting a datasource in a bean
Sounds like a plan,I've never worked with javax.naming packages before though, I've got the following datasource Cound you give me some example code that uses JNDI to get a connection? ~/nick On Sun, 2003-01-05 at 17:46, Max Kremer wrote: > You can just look up the JNDI datasource in your bean. > - Original Message - > From: "Nick Torenvliet" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Sunday, January 05, 2003 4:51 PM > Subject: getting a datasource in a bean > > > > Hi, Just as in the examples on the struts site I've succesfully > > configured a mysql datasource and had it print the results of queries > > from out of an action class. I am using struts 1.1-b2. > > > > I want to replace my current dbpooling(I wrote last year)with the struts > > datasource and dbcp, I am having one problem though. I can't get a > > connection in my beans to the database because I have no access to the > > getDataSource(request,key) method. Since my pooling methods were hard > > wired I just went in to the database by passing a database name to the > > methods. > > > > The stock answer is to pass a connection to the bean, but that means > > I'll be rewriting a lot of code. > > > > How can I access the datasource from a bean? > > > > ~/nick > > > > > > -- > > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > - > > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: getting a datasource in a bean
You can just look up the JNDI datasource in your bean. - Original Message - From: "Nick Torenvliet" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, January 05, 2003 4:51 PM Subject: getting a datasource in a bean > Hi, Just as in the examples on the struts site I've succesfully > configured a mysql datasource and had it print the results of queries > from out of an action class. I am using struts 1.1-b2. > > I want to replace my current dbpooling(I wrote last year)with the struts > datasource and dbcp, I am having one problem though. I can't get a > connection in my beans to the database because I have no access to the > getDataSource(request,key) method. Since my pooling methods were hard > wired I just went in to the database by passing a database name to the > methods. > > The stock answer is to pass a connection to the bean, but that means > I'll be rewriting a lot of code. > > How can I access the datasource from a bean? > > ~/nick > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > - > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
getting a datasource in a bean
Hi, Just as in the examples on the struts site I've succesfully configured a mysql datasource and had it print the results of queries from out of an action class. I am using struts 1.1-b2. I want to replace my current dbpooling(I wrote last year)with the struts datasource and dbcp, I am having one problem though. I can't get a connection in my beans to the database because I have no access to the getDataSource(request,key) method. Since my pooling methods were hard wired I just went in to the database by passing a database name to the methods. The stock answer is to pass a connection to the bean, but that means I'll be rewriting a lot of code. How can I access the datasource from a bean? ~/nick -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Struts data-source vs. Tomcat JNDI registered DataSource
On Fri, 3 Jan 2003, Charlie Toohey wrote: > Date: Fri, 3 Jan 2003 12:09:29 -0800 > From: Charlie Toohey <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Struts data-source vs. Tomcat JNDI registered DataSource > > For those using Struts with Tomcat, > Any advantage or difference in using a Struts data source based on the > Jakarta Commons DataBase Connection Pool BasicDataSource class, > vs. using the Tomcat data source using the Jakarta Commons DBCP and > Pool (configuring factory as org.apache.commons.dbcp.BasicDataSourceFactory), > registering the DataSource with a naming service based on JNDI ? > Struts 1.1 and Tomcat 4.1 both use commons-dbcp under the covers. > I was planning on configuring a DataSource with JNDI in web.xml/server.xml > for database access, but then noticed that struts-config.xml has a > data-source entry. > Using JNDI is portable to any J2EE based app server, plus any servlet container that supports the JNDI namespace (i.e. like Tomcat 4.x). In addition, the logic required to get a connection from the pool does *not* need to have a reference to the DataSource or ServletContext, which means your business logic can become more insulated from the web tier. Further, the JNDI data source itself is configured external to your webapp, so you don't have to tweak the web.xml file to adjust for differences (example - you can install the exact same webapp on a development, test, and production server without having to tweak it to connect to the correct database.) Finally, using JNDI means that you'll automatically take advantage of the connection pool provided by your app server container (if you ever run on something other than Tomcat), which is likely to be optimized for performance on that container. The only downside to using JNDI is that your business logic *must* run inside a container that provides the JNDI services, or your app must otherwise supply one. If this is not a problem for you, I'd *always* go the JNDI route. > Any opinions ? > > - Charlie Craig McClanahan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
RE: Struts data-source vs. Tomcat JNDI registered DataSource
JNDI is way too easy. Regards, PQ "This Guy Thinks He Knows Everything" "This Guy Thinks He Knows What He Is Doing" -Original Message- From: Charlie Toohey [mailto:[EMAIL PROTECTED]] Sent: January 3, 2003 3:09 PM To: [EMAIL PROTECTED] Subject: Struts data-source vs. Tomcat JNDI registered DataSource For those using Struts with Tomcat, Any advantage or difference in using a Struts data source based on the Jakarta Commons DataBase Connection Pool BasicDataSource class, vs. using the Tomcat data source using the Jakarta Commons DBCP and Pool (configuring factory as org.apache.commons.dbcp.BasicDataSourceFactory), registering the DataSource with a naming service based on JNDI ? I was planning on configuring a DataSource with JNDI in web.xml/server.xml for database access, but then noticed that struts-config.xml has a data-source entry. Any opinions ? - Charlie -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Struts data-source vs. Tomcat JNDI registered DataSource
For those using Struts with Tomcat, Any advantage or difference in using a Struts data source based on the Jakarta Commons DataBase Connection Pool BasicDataSource class, vs. using the Tomcat data source using the Jakarta Commons DBCP and Pool (configuring factory as org.apache.commons.dbcp.BasicDataSourceFactory), registering the DataSource with a naming service based on JNDI ? I was planning on configuring a DataSource with JNDI in web.xml/server.xml for database access, but then noticed that struts-config.xml has a data-source entry. Any opinions ? - Charlie -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: datasource problem
>>>>> "Steven" == Steven Dahlin <[EMAIL PROTECTED]> writes: Steven> I am a little unclear what you mean by using modules? If you don't know what they are, then you probably aren't using them :) . It's a mechanism that allows you to subdivide your Struts application into pieces, each with their own config file. If you're not using modules, then I don't know what the problem could be. Perhaps you could use your debugger to trace the loading of your struts-config.xml file, especially when it stores the data-soure configuration? David> - Original Message - David> From: "David M. Karr" <[EMAIL PROTECTED]> >> >>>>> "Steven" == Steven Dahlin <[EMAIL PROTECTED]> writes: >> Steven> When I try to get a datasource which has been defined in the Steven> struts-config.xml no matter what I do the datasource returns back null. My Steven> struts-config.xml for data-sources is: Steven> >> Steven> >> Steven> value = "false"/> Steven> value = "database source"/> Steven> value = Steven> "oracle.jdbc.driver.OracleDriver"/> Steven> value = "theuser"/> Steven> value = "thepassword"/> Steven> value = Steven> "jdbc:oracle:thin:@192.192.192.192:1675:inst"/> Steven> >> Steven> >> Steven> In the section of code used for initialization of the Steven> datasource there is the following: >> Steven> ServletContext context = Steven> actSrv.getServletContext(); Steven> dsSrc= ( DataSource ) context.getAttribute( Steven> "ConPool" ); >> Steven> The context is captured but the datasource remains null. >> >> Are you using modules? The data-source is put into the ServletContext David> with a >> key that is constructed by appending the module prefix to the given key. -- === David M. Karr ; Java/J2EE/XML/Unix/C++ [EMAIL PROTECTED] ; SCJP -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: datasource problem
I am a little unclear what you mean by using modules? Steve - Original Message - From: "David M. Karr" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 01, 2003 3:45 PM Subject: Re: datasource problem > >>>>> "Steven" == Steven Dahlin <[EMAIL PROTECTED]> writes: > > Steven> When I try to get a datasource which has been defined in the struts-config.xml no matter what I do the datasource returns back null. My struts-config.xml for data-sources is: > Steven> > > Steven> > > Steven> Steven>value = "false"/> > Steven> Steven>value = "database source"/> > Steven> Steven>value = "oracle.jdbc.driver.OracleDriver"/> > Steven> Steven>value = "theuser"/> > Steven> Steven>value = "thepassword"/> > Steven> Steven> value = "jdbc:oracle:thin:@192.192.192.192:1675:inst"/> > Steven> > > Steven> > > Steven> In the section of code used for initialization of the datasource there is the following: > > Steven> ServletContext context = actSrv.getServletContext(); > Steven> dsSrc= ( DataSource ) context.getAttribute( "ConPool" ); > > Steven> The context is captured but the datasource remains null. > > Are you using modules? The data-source is put into the ServletContext with a > key that is constructed by appending the module prefix to the given key. > > -- > === > David M. Karr ; Java/J2EE/XML/Unix/C++ > [EMAIL PROTECTED] ; SCJP > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: datasource problem
>>>>> "Steven" == Steven Dahlin <[EMAIL PROTECTED]> writes: Steven> When I try to get a datasource which has been defined in the struts-config.xml no matter what I do the datasource returns back null. My struts-config.xml for data-sources is: Steven> Steven> Steven> value = "false"/> Steven> value = "database source"/> Steven> value = "oracle.jdbc.driver.OracleDriver"/> Steven> value = "theuser"/> Steven> value = "thepassword"/> Steven> value = "jdbc:oracle:thin:@192.192.192.192:1675:inst"/> Steven> Steven> Steven> In the section of code used for initialization of the datasource there is the following: Steven> ServletContext context = actSrv.getServletContext(); Steven> dsSrc= ( DataSource ) context.getAttribute( "ConPool" ); Steven> The context is captured but the datasource remains null. Are you using modules? The data-source is put into the ServletContext with a key that is constructed by appending the module prefix to the given key. -- === David M. Karr ; Java/J2EE/XML/Unix/C++ [EMAIL PROTECTED] ; SCJP -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: "conPool" --> "ConPool" / Re: datasource problem
That was a misttype on my part. In the code both have "conPool". - Original Message - From: "Liu Jian" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, January 01, 2003 2:25 PM Subject: "conPool" --> "ConPool" / Re: datasource problem > Will the data-source key case-sensitive? "conPool" --> "ConPool" > > Try > > dsSrc= ( DataSource ) context.getAttribute( "conPool" ); > > Good luck ! > > > > - Original Message - > From: "Steven Dahlin" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, January 01, 2003 3:42 PM > Subject: datasource problem > > > When I try to get a datasource which has been defined in the > struts-config.xml no matter what I do the datasource returns back null. My > struts-config.xml for data-sources is: > > > > > > value = "false"/> > value = "database source"/> > value = "oracle.jdbc.driver.OracleDriver"/> > value = "theuser"/> > value = "thepassword"/> > value = > "jdbc:oracle:thin:@192.192.192.192:1675:inst"/> > > > > > In the section of code used for initialization of the datasource there is > the following: > > ServletContext context = actSrv.getServletContext(); > dsSrc= ( DataSource ) context.getAttribute( "ConPool" ); > > The context is captured but the datasource remains null. > > Any suggestions? > > Thanks, > Steve > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
"conPool" --> "ConPool" / Re: datasource problem
Will the data-source key case-sensitive? "conPool" --> "ConPool" Try dsSrc= ( DataSource ) context.getAttribute( "conPool" ); Good luck ! - Original Message - From: "Steven Dahlin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 01, 2003 3:42 PM Subject: datasource problem When I try to get a datasource which has been defined in the struts-config.xml no matter what I do the datasource returns back null. My struts-config.xml for data-sources is: In the section of code used for initialization of the datasource there is the following: ServletContext context = actSrv.getServletContext(); dsSrc= ( DataSource ) context.getAttribute( "ConPool" ); The context is captured but the datasource remains null. Any suggestions? Thanks, Steve -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
datasource problem
When I try to get a datasource which has been defined in the struts-config.xml no matter what I do the datasource returns back null. My struts-config.xml for data-sources is: In the section of code used for initialization of the datasource there is the following: ServletContext context = actSrv.getServletContext(); dsSrc= ( DataSource ) context.getAttribute( "ConPool" ); The context is captured but the datasource remains null. Any suggestions? Thanks, Steve
FW: Digester - Config.xml - datasource
Sorry people, but I could do with some feedback on this rather than finding out the hard way.. Up up against the wire I I want to get my flight back home for christmas.. Anyone done this? Is my question silly (would be the first time)? Many thanks mark -- Forwarded Message From: Mark <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Date: Thu, 19 Dec 2002 01:14:29 +0100 To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Digester - Config.xml - datasource Hello I'm wondering whether anyone has every used digester to read in properties from config.xml and then addSetProperty to change a couple of values.. E.g. Now I want to make a connection to pretty much the same db etc.. Has anyone tried. Digester newdatasource = new Digester(); newdatasource . addObjectCreate("datasources/datasource", "DataSource"); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","key","my key²); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","username ","ricky²); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","password ","bianca²); //Some means of reading in the properties that I don¹t want to change, but I haven¹t found yet.. Etc Javax.sql.DataSource ds = getDatasource(³mykey²); Will this work? Has anyone done this., Many thanks in advance and seasonal felicitations -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- End of Forwarded Message -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Digester - Config.xml - datasource
Hello I'm wondering whether anyone has every used digester to read in properties from config.xml and then addSetProperty to change a couple of values.. E.g. Now I want to make a connection to pretty much the same db etc.. Has anyone tried. Digester newdatasource = new Digester(); newdatasource . addObjectCreate("datasources/datasource", "DataSource"); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","key","my key²); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","username ","ricky²); newdatasource .AddSetProperty("struts-config/datasources/datasource/setproperty","password ","bianca²); //Some means of reading in the properties that I don¹t want to change, but I haven¹t found yet.. Etc Javax.sql.DataSource ds = getDatasource(³mykey²); Will this work? Has anyone done this., Many thanks in advance and seasonal felicitations -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Oracle DataSource Tips
One tactic I have used is to create a singleton data access class (e.g. DataCache) which provides methods that return data as beans (not action form beans). The DataCache class gets initialized in a Struts plug-in. Plug-ins execute once when the application starts and once when it shuts down, and require Struts 1.1. The beans can do the business logic processing as needed. The plug-in has access to the servlet context so can access the datasource defined in struts-config.xml or in the servlet container configuration file(s). Brad Mark .it> cc: Subject: Re: Oracle DataSource Tips 17-12-02 01:09 Please respond to "Struts Users Mailing List" Hello I'm using oracle as my datsource as well, I haven't had this problem but that in my earlier posting.. So who do you reference the datasource specifed in config.xml in business logic classes. The docs recommend this seperation but provide no clear way of doing this, am i missing something? Many thanks mark -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Oracle DataSource Tips
Hello I'm using oracle as my datsource as well, I haven't had this problem but that in my earlier posting.. So who do you reference the datasource specifed in config.xml in business logic classes. The docs recommend this seperation but provide no clear way of doing this, am i missing something? Many thanks mark On 16-12-2002 22:01, "Bradley G Smith" <[EMAIL PROTECTED]> wrote: > Since it took me several hours to catch this bug, I thought I might pass it > along to anyone using Oracle as a datasource for the Struts application. > > The OracleDatSource and OraclePooledConnectionDataSource classes use > standard Bean naming conventions for getters and setters. The url property, > however, uses setURL and getURL for the setter and getter respectively. > Therefore, the set-property element in the datasource clause should be > instead of > . > > A valid datasource definition that is working for me is: > > > type > ="oracle.jdbc.pool.OracleConnectionPoolDataSource"> > value="valid_pass" /> > value="valid_user" /> > value="Application Data Resource" /> > value="jdbc:oracle:thin: > @xxx.xxx.xxx.xxx:1521:a" /> > > > > The xxx.xxx.xxx.xxx value is an IP or resolvable hostname for the oracle > server. 1521 is the port to use. "a" is the instance name for the database. > The key is an arbitrary string. > > If you choose instead to use the default connection pool from Struts (via > the Commons database package) then the ping that works for Oracle is > "select 1 from dual". Dual is a virtual table in every Oracle instance. > > Brad > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Oracle DataSource Tips
This might be a little more readable (w/ correction). Formatting courtesy of Notes. Brad "Bradley G Smith" To: [EMAIL PROTECTED] <[EMAIL PROTECTED] cc: d.us>Subject: Oracle DataSource Tips 16-12-02 13:01 Please respond to "Struts Users Mailing List" -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Oracle DataSource Tips
Since it took me several hours to catch this bug, I thought I might pass it along to anyone using Oracle as a datasource for the Struts application. The OracleDatSource and OraclePooledConnectionDataSource classes use standard Bean naming conventions for getters and setters. The url property, however, uses setURL and getURL for the setter and getter respectively. Therefore, the set-property element in the datasource clause should be instead of . A valid datasource definition that is working for me is: The xxx.xxx.xxx.xxx value is an IP or resolvable hostname for the oracle server. 1521 is the port to use. "a" is the instance name for the database. The key is an arbitrary string. If you choose instead to use the default connection pool from Struts (via the Commons database package) then the ping that works for Oracle is "select 1 from dual". Dual is a virtual table in every Oracle instance. Brad -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Multiple DataSource Problem
Hmm, I don't see anything wrong with that. What version of Struts are you using? You should check the struts-config_1_1.dtd (or appropriate version number) for available elements and attributes. The xml errors indicate you have an element missing the property attribute. David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Fri, 6 Dec 2002 14:23:55 -0600 ="oracle.jdbc.driver.OracleDriver"/> ="oracle.jdbc.driver.OracleDriver"/> Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/06/2002 02:21 PM Please respond to "Struts Users Mailing List" Ok, post your entire section. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Fri, 6 Dec 2002 13:57:36 -0600 > > >That gives me a xml parse error: > >-INF/struts-config.xml: XML-0138: (Error) REQUIRED >attribute 'property' is not >pecified. >file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts >config.xml: XML-0138: (Error) REQUIRED attribute >'property' is not specified.> >org.xml.sax.SAXParseException: >file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-config.xml >Line 17, Column 34>: XML-0138: (Error) REQUIRED attribute 'value' is not >specified. > at >oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:231) > at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:156) > at >oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) > at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) > at org.apache.commons.digester.Digester.parse(Digester.java:1495) > at >org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) > at >org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) > at javax.servlet.GenericServlet.init(GenericServlet.java:44) > at >com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) > at >com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) > at >com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) > at >com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) > at >com.evermind.server.http.HttpApplication.(HttpApplication.java:376) > at >com.evermind.server.Application.getHttpApplication(Application.java:657) > at >com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) > at >com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) > at >com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) > at >com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) > at >com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) >[ERROR] Digester - -Parse Error at line 17 column 34: >file:/C:/oracle/j2ee/home/applications/MRA/WE >-INF/struts-config.xml: XML-0138: (Error) REQUIRED >attribute 'value' is not spe >ified. >file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-co >fig.xml: XML-0138: (Error) REQUIRED attribute 'value' >is not specified.> >oracle.xml.parser.v2.XMLParseException: Attribute 'key' used but not >declared. > at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:208) > at >oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) > at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) > at org.apache.commons.digester.Digester.parse(Digester.java:1495) > at >org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) > at >org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) > at javax.servlet.GenericServlet.init(GenericServlet.ja
Re: Multiple DataSource Problem
Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/06/2002 02:21 PM Please respond to "Struts Users Mailing List" Ok, post your entire section. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Fri, 6 Dec 2002 13:57:36 -0600 > > >That gives me a xml parse error: > >-INF/struts-config.xml: XML-0138: (Error) REQUIRED >attribute 'property' is not >pecified. file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts >config.xml: XML-0138: (Error) REQUIRED attribute >'property' is not specified.> >org.xml.sax.SAXParseException: >file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-config.xml >Line 17, Column 34>: XML-0138: (Error) REQUIRED attribute 'value' is not >specified. > at >oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:231) > at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:156) > at >oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) > at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) > at org.apache.commons.digester.Digester.parse(Digester.java:1495) > at >org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) > at >org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) > at javax.servlet.GenericServlet.init(GenericServlet.java:44) > at >com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) > at >com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) > at >com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) > at >com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) > at >com.evermind.server.http.HttpApplication.(HttpApplication.java:376) > at >com.evermind.server.Application.getHttpApplication(Application.java:657) > at >com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) > at >com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) > at >com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) > at >com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) > at >com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) >[ERROR] Digester - -Parse Error at line 17 column 34: >file:/C:/oracle/j2ee/home/applications/MRA/WE >-INF/struts-config.xml: XML-0138: (Error) REQUIRED >attribute 'value' is not spe >ified. file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-co >fig.xml: XML-0138: (Error) REQUIRED attribute 'value' >is not specified.> >oracle.xml.parser.v2.XMLParseException: Attribute 'key' used but not >declared. > at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:208) > at >oracle.xml.parser.v2.NonValidat
Re: Multiple DataSource Problem
Ok, post your entire section. David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Fri, 6 Dec 2002 13:57:36 -0600 That gives me a xml parse error: -INF/struts-config.xml: XML-0138: (Error) REQUIRED attribute 'property' is not pecified. file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts config.xml: XML-0138: (Error) REQUIRED attribute 'property' is not specified.> org.xml.sax.SAXParseException: file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-config.xml Line 17, Column 34>: XML-0138: (Error) REQUIRED attribute 'value' is not specified. at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:231) at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:156) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) at org.apache.commons.digester.Digester.parse(Digester.java:1495) at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) at javax.servlet.GenericServlet.init(GenericServlet.java:44) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) at com.evermind.server.http.HttpApplication.(HttpApplication.java:376) at com.evermind.server.Application.getHttpApplication(Application.java:657) at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) [ERROR] Digester - -Parse Error at line 17 column 34: file:/C:/oracle/j2ee/home/applications/MRA/WE -INF/struts-config.xml: XML-0138: (Error) REQUIRED attribute 'value' is not spe ified. file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-co fig.xml: XML-0138: (Error) REQUIRED attribute 'value' is not specified.> oracle.xml.parser.v2.XMLParseException: Attribute 'key' used but not declared. at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:208) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) at org.apache.commons.digester.Digester.parse(Digester.java:1495) at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) at javax.servlet.GenericServlet.init(GenericServlet.java:44) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) at com.evermind.server.http.HttpApplication.(HttpApplication.java:376) at com.evermind.server.Application.getHttpApplication(Application.java:657) at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) [ERROR] ActionServlet - -Parsing error processing resource path /WEB-INF/struts-config.xml ml.parser.v2.XMLParseException: Attribute 'key' used but not declared.> Any other ideas? I am willing to try anything. Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/06/2002 01:39 PM Please respond to "Struts Users Mailing List"
Re: Multiple DataSource Problem
That gives me a xml parse error: -INF/struts-config.xml: XML-0138: (Error) REQUIRED attribute 'property' is not pecified. : XML-0138: (Error) REQUIRED attribute 'property' is not specified.> org.xml.sax.SAXParseException: file:/C:/oracle/j2ee/home/applications/MRA/WEB-INF/struts-config.xml Line 17, Column 34>: XML-0138: (Error) REQUIRED attribute 'value' is not specified. at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:231) at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:156) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) at org.apache.commons.digester.Digester.parse(Digester.java:1495) at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) at javax.servlet.GenericServlet.init(GenericServlet.java:44) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) at com.evermind.server.http.HttpApplication.(HttpApplication.java:376) at com.evermind.server.Application.getHttpApplication(Application.java:657) at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) [ERROR] Digester - -Parse Error at line 17 column 34: file:/C:/oracle/j2ee/home/applications/MRA/WE -INF/struts-config.xml: XML-0138: (Error) REQUIRED attribute 'value' is not spe ified. : XML-0138: (Error) REQUIRED attribute 'value' is not specified.> oracle.xml.parser.v2.XMLParseException: Attribute 'key' used but not declared. at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:208) at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:268) at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:145) at org.apache.commons.digester.Digester.parse(Digester.java:1495) at org.apache.struts.action.ActionServlet.initApplicationConfig(ActionServlet.java:860) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:455) at javax.servlet.GenericServlet.init(GenericServlet.java:44) at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:1673) at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4006) at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4105) at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:579) at com.evermind.server.http.HttpApplication.(HttpApplication.java:376) at com.evermind.server.Application.getHttpApplication(Application.java:657) at com.evermind.server.http.HttpServer.getHttpApplication(HttpServer.java:663) at com.evermind.server.http.HttpSite.getApplication(HttpSite.java:387) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:378) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243) at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64) [ERROR] ActionServlet - -Parsing error processing resource path /WEB-INF/struts-config.xml Any other ideas? I am willing to try anything. Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/06/2002 01:39 PM Please respond to
Re: Multiple DataSource Problem
Try my original suggestion: David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Fri, 6 Dec 2002 13:02:34 -0600 Ok I have tried that and I am getting a null pointer exception caused by the DataSource, here is my code ServletContext context = servlet.getServletContext(); DataSource dataSource = (DataSource) context.getAttribute("MRA"); conn = dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); My struts.xml is this; ="oracle.jdbc.driver.OracleDriver"/> ="oracle.jdbc.driver.OracleDriver"/> I dont see what I am doing wrong please help. Thank you Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/06/2002 12:45 PM Please respond to "Struts Users Mailing List" From action.execute() DataSource ds1 = (DataSource)this.getServlet().getServletContext().getAttribute ("YOUR_DS_KEY")); David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Fri, 6 Dec 2002 12:30:36 -0600 > > >Ok , I thought I have already changed the key value's to "MRA" and >"PHONE_DB" in both of my data-sources, what I am having trouble with is how >do I refrence these values in the form and action classes? > > >Tim Bachta >Information Technology >MC 48 > > > > "David Graham" > >[EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 04:09 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > > > >That would store the DataSource under the Struts default value, which >obviously only allows for one DataSource. Just change the key value to >something else to store multiple DataSources. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Subject: Re: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 15:01:21 -0600 > > > > > >Can you show me a code snip of how to use this? > > > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > > "David Graham" > > > >[EMAIL PROTECTED] > > ail.com> cc: > >Subject: Re: Multiple > >DataSource Problem > > 12/05/2002 02:45 > > PM > > Please respond to > > "Struts Users > > Mailing List" > > > > > > > > > > > > > >Use the key attribute of the data-source element. > > > >David > > > > > > > > > > > > > > >From: [EMAIL PROTECTED] > > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > >Subject: Re: Multiple DataSource Problem > > >Date: Thu, 5 Dec 2002 14:02:31 -0600 > > > > > > > > >Did I not give each data-source element its own key? > > > > > >Tim Bachta > > >Information Technology > > >MC 48 > > > > > > > > > > > > > > > "David Graham" > > > > > >[EMAIL PROTECTED] > > > ail.com>
Re: Multiple DataSource Problem
Ok I have tried that and I am getting a null pointer exception caused by the DataSource, here is my code ServletContext context = servlet.getServletContext(); DataSource dataSource = (DataSource) context.getAttribute("MRA"); conn = dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); My struts.xml is this; I dont see what I am doing wrong please help. Thank you Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/06/2002 12:45 PM Please respond to "Struts Users Mailing List" >From action.execute() DataSource ds1 = (DataSource)this.getServlet().getServletContext().getAttribute ("YOUR_DS_KEY")); David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Fri, 6 Dec 2002 12:30:36 -0600 > > >Ok , I thought I have already changed the key value's to "MRA" and >"PHONE_DB" in both of my data-sources, what I am having trouble with is how >do I refrence these values in the form and action classes? > > >Tim Bachta >Information Technology >MC 48 > > > > "David Graham" > [EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 04:09 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > > > >That would store the DataSource under the Struts default value, which >obviously only allows for one DataSource. Just change the key value to >something else to store multiple DataSources. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Subject: Re: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 15:01:21 -0600 > > > > > >Can you show me a code snip of how to use this? > > > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > > "David Graham" > >>[EMAIL PROTECTED] > > ail.com> cc: > >Subject: Re: Multiple > >DataSource Problem > > 12/05/2002 02:45 > > PM > > Please respond to > > "Struts Users > > Mailing List" > > > > > > > > > > > > > >Use the key attribute of the data-source element. > > > >David > > > > > > > > > > > > > > >From: [EMAIL PROTEC
Re: Multiple DataSource Problem
From action.execute() DataSource ds1 = (DataSource)this.getServlet().getServletContext().getAttribute("YOUR_DS_KEY")); David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Fri, 6 Dec 2002 12:30:36 -0600 Ok , I thought I have already changed the key value's to "MRA" and "PHONE_DB" in both of my data-sources, what I am having trouble with is how do I refrence these values in the form and action classes? Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/05/2002 04:09 PM Please respond to "Struts Users Mailing List" That would store the DataSource under the Struts default value, which obviously only allows for one DataSource. Just change the key value to something else to store multiple DataSources. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 15:01:21 -0600 > > >Can you show me a code snip of how to use this? > > >Tim Bachta >Information Technology >MC 48 > > > > > "David Graham" > >[EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 02:45 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > >Use the key attribute of the data-source element. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Subject: Re: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 14:02:31 -0600 > > > > > >Did I not give each data-source element its own key? > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > > "David Graham" > > > >[EMAIL PROTECTED] > > ail.com> cc: > >Subject: Re: Multiple > >DataSource Problem > > 12/05/2002 01:41 > > PM > > Please respond to > > "Struts Users > > Mailing List" > > > > > > > > > > > > > >You need to give each data-source element its own key. Struts stores the > >DataSource under that key in the ServletContext. > > > >David > > > > > > > > > > > > > > >From: [EMAIL PROTECTED] > > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > >To: [EMAIL PROTECTED] > > >Subject: Multiple DataSource Problem > > >Date: Thu, 5 Dec 2002 13:20:01 -0600 > > > > > >I am having trouble getting multiple datasources to work in my > >application. > > >I have searched the archives and found inofrmation on how to do it but > >the > > >solutions given are depricated. Can anyone help me? > > > > > > > > > > > > > > > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > >value="jdbc:oracle:thin: > > >@147.101.104.63:1524:common"/> > > > > > > > > > > > > > > > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > >value="jdbc:oracle:thin: > > >@oid:1521:infoprd"/> > > > > > > >value="info_user"/> > > > > > > > > > > >
Re: Multiple DataSource Problem
Ok , I thought I have already changed the key value's to "MRA" and "PHONE_DB" in both of my data-sources, what I am having trouble with is how do I refrence these values in the form and action classes? Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/05/2002 04:09 PM Please respond to "Struts Users Mailing List" That would store the DataSource under the Struts default value, which obviously only allows for one DataSource. Just change the key value to something else to store multiple DataSources. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 15:01:21 -0600 > > >Can you show me a code snip of how to use this? > > >Tim Bachta >Information Technology >MC 48 > > > > > "David Graham" > [EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 02:45 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > >Use the key attribute of the data-source element. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >Subject: Re: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 14:02:31 -0600 > > > > > >Did I not give each data-source element its own key? > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > > "David Graham" > >>[EMAIL PROTECTED] > > ail.com> cc: > > Subject: Re: Multiple > >DataSource Problem > > 12/05/2002 01:41 > > PM > > Please respond to > > "Struts Users > > Mailing List" > > > > > > > > > > > > > >You need to give each data-source element its own key. Struts stores the > >DataSource under that key in the ServletContext. > > > >David > > > > > > > > > > > > > > >From: [EMAIL PROTECTED] > > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > >To: [EMAIL PROTECTED] > > >Subject: Multiple DataSource Problem > > >Date: Thu, 5 Dec 2002 13:20:01 -0600 > > > > > >I am having trouble getting multiple datasources to work in my > >application. > > >I have searched the archives and found inofrmation on how to do it but > >the > > >solutions given are depricated. Can anyone help me? > > > > > > > > > > > > > > > > > >&
Re: Multiple DataSource Problem
That would store the DataSource under the Struts default value, which obviously only allows for one DataSource. Just change the key value to something else to store multiple DataSources. David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Thu, 5 Dec 2002 15:01:21 -0600 Can you show me a code snip of how to use this? Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/05/2002 02:45 PM Please respond to "Struts Users Mailing List" Use the key attribute of the data-source element. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 14:02:31 -0600 > > >Did I not give each data-source element its own key? > >Tim Bachta >Information Technology >MC 48 > > > > > "David Graham" > >[EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 01:41 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > >You need to give each data-source element its own key. Struts stores the >DataSource under that key in the ServletContext. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: [EMAIL PROTECTED] > >Subject: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 13:20:01 -0600 > > > >I am having trouble getting multiple datasources to work in my >application. > >I have searched the archives and found inofrmation on how to do it but >the > >solutions given are depricated. Can anyone help me? > > > > > > > > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > > > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > > > > > > > > > > >try > > { > > ServletContext context = servlet.getServletContext(); > > DataSource dataSource = (DataSource) > >context.getAttribute(Action.DATA_SOURCE_KEY); > > conn = dataSource.getConnection(); > > stmt = conn.createStatement(); > > rs = stmt.executeQuery(sql); > > > > Thank you for your help > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > >-- > >To unsubscribe, e-mail: > ><mailto:[EMAIL PROTECTED]> > >For additional commands, e-mail: > ><mailto:[EMAIL PROTECTED]> > > >_ >MSN 8 with e-mail virus protection service: 2 months FREE* >http://join.msn.com/?page=features/virus > > >-- >To unsubscribe, e-mail: < >mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: < >mailto:[EMAIL PROTECTED]> > > > > > > > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED]> For additional commands, e-mail: < mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Multiple DataSource Problem
Can you show me a code snip of how to use this? Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/05/2002 02:45 PM Please respond to "Struts Users Mailing List" Use the key attribute of the data-source element. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >Subject: Re: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 14:02:31 -0600 > > >Did I not give each data-source element its own key? > >Tim Bachta >Information Technology >MC 48 > > > > > "David Graham" > [EMAIL PROTECTED] > ail.com> cc: >Subject: Re: Multiple >DataSource Problem > 12/05/2002 01:41 > PM > Please respond to > "Struts Users > Mailing List" > > > > > > >You need to give each data-source element its own key. Struts stores the >DataSource under that key in the ServletContext. > >David > > > > > > > >From: [EMAIL PROTECTED] > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >To: [EMAIL PROTECTED] > >Subject: Multiple DataSource Problem > >Date: Thu, 5 Dec 2002 13:20:01 -0600 > > > >I am having trouble getting multiple datasources to work in my >application. > >I have searched the archives and found inofrmation on how to do it but >the > >solutions given are depricated. Can anyone help me? > > > > > > > > > > > >>="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > > > > > > >>="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > > > > > > > > > > >try > > { > > ServletContext context = servlet.getServletContext(); > > DataSource dataSource = (DataSource) > >context.getAttribute(Action.DATA_SOURCE_KEY); > > conn = dataSource.getConnection(); > > stmt = conn.createStatement(); > > rs = stmt.executeQuery(sql); > > > > Thank you for your help > > > >Tim Bachta > >Information Technology > >MC 48 > > > > > > > > > >-- > >To unsubscribe, e-mail: > ><mailto:[EMAIL PROTECTED]> > >For additional commands, e-mail: > ><mailto:[EMAIL PROTECTED]> > > >_ >MSN 8 with e-mail virus protection service: 2 months FREE* >http://join.msn.com/?page=features/virus > > >-- >To unsubscribe, e-mail: < >mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: < >mailto:[EMAIL PROTECTED]> > > > > > > > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED]> For additional commands, e-mail: < mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Multiple DataSource Problem
Use the key attribute of the data-source element. David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: Re: Multiple DataSource Problem Date: Thu, 5 Dec 2002 14:02:31 -0600 Did I not give each data-source element its own key? Tim Bachta Information Technology MC 48 "David Graham" ail.com> cc: Subject: Re: Multiple DataSource Problem 12/05/2002 01:41 PM Please respond to "Struts Users Mailing List" You need to give each data-source element its own key. Struts stores the DataSource under that key in the ServletContext. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 13:20:01 -0600 > >I am having trouble getting multiple datasources to work in my application. >I have searched the archives and found inofrmation on how to do it but the >solutions given are depricated. Can anyone help me? > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > > > > > >="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > >try > { > ServletContext context = servlet.getServletContext(); > DataSource dataSource = (DataSource) >context.getAttribute(Action.DATA_SOURCE_KEY); > conn = dataSource.getConnection(); > stmt = conn.createStatement(); > rs = stmt.executeQuery(sql); > > Thank you for your help > >Tim Bachta >Information Technology >MC 48 > > > > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED]> For additional commands, e-mail: < mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Multiple DataSource Problem
Did I not give each data-source element its own key? Tim Bachta Information Technology MC 48 "David Graham" cc: Subject: Re: Multiple DataSource Problem 12/05/2002 01:41 PM Please respond to "Struts Users Mailing List" You need to give each data-source element its own key. Struts stores the DataSource under that key in the ServletContext. David >From: [EMAIL PROTECTED] >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Multiple DataSource Problem >Date: Thu, 5 Dec 2002 13:20:01 -0600 > >I am having trouble getting multiple datasources to work in my application. >I have searched the archives and found inofrmation on how to do it but the >solutions given are depricated. Can anyone help me? > > > > > > ="oracle.jdbc.driver.OracleDriver"/> > > > > > > > ="oracle.jdbc.driver.OracleDriver"/> > > > > > > > > >try > { > ServletContext context = servlet.getServletContext(); > DataSource dataSource = (DataSource) >context.getAttribute(Action.DATA_SOURCE_KEY); > conn = dataSource.getConnection(); > stmt = conn.createStatement(); > rs = stmt.executeQuery(sql); > > Thank you for your help > >Tim Bachta >Information Technology >MC 48 > > > > >-- >To unsubscribe, e-mail: ><mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: ><mailto:[EMAIL PROTECTED]> _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED]> For additional commands, e-mail: < mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: Multiple DataSource Problem
You need to give each data-source element its own key. Struts stores the DataSource under that key in the ServletContext. David From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Multiple DataSource Problem Date: Thu, 5 Dec 2002 13:20:01 -0600 I am having trouble getting multiple datasources to work in my application. I have searched the archives and found inofrmation on how to do it but the solutions given are depricated. Can anyone help me? ="oracle.jdbc.driver.OracleDriver"/> ="oracle.jdbc.driver.OracleDriver"/> try { ServletContext context = servlet.getServletContext(); DataSource dataSource = (DataSource) context.getAttribute(Action.DATA_SOURCE_KEY); conn = dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); Thank you for your help Tim Bachta Information Technology MC 48 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Multiple DataSource Problem
I am having trouble getting multiple datasources to work in my application. I have searched the archives and found inofrmation on how to do it but the solutions given are depricated. Can anyone help me? try { ServletContext context = servlet.getServletContext(); DataSource dataSource = (DataSource) context.getAttribute(Action.DATA_SOURCE_KEY); conn = dataSource.getConnection(); stmt = conn.createStatement(); rs = stmt.executeQuery(sql); Thank you for your help Tim Bachta Information Technology MC 48 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: DataSource
I know the feeling, anyone would think this a perl mailing list. Try this puppy.. It works. import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.*; import java.sql.*; import javax.sql.DataSource; public class LoginAction extends Action { /** * * * * */ public ActionForward perform( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LoginForm theForm = (LoginForm) form; String username = theForm.getUsername(); String password = theForm.getPassword(); String company = theForm.getCompany(); try { DataSource dataSource = servlet.findDataSource(null); Connection conn = dataSource.getConnection(); String query = "SELECT "+ "users.name,"+ "FROM users,companies "+ "WHERE users.username = '"+ username +"' "; Statement stmt = conn.createStatement (); ResultSet rs = stmt.executeQuery(query); HttpSession session = request.getSession(); if(rs.next()) { return (mapping.findForward("sucess")); } else { return (mapping.findForward("failure")); } } catch (SQLException e) { e.printStackTrace(); } } } On 27-11-2002 20:35, "Jim Bruno Goldberg" <[EMAIL PROTECTED]> wrote: > > I try this code, but I dont work because I don known where is > dataSource. Can someone a .java complete (with imports)? Thanks a lot. > > Gemes Tibor wrote: >> >> 2002. november 27. 12:49 dátummal Jim Bruno Goldberg ezt írtad: >>> Hi, people! >>> >>> Someone can send me a example class with DataSource access >>> defined on >>> struts-config? How can I do this? I don find any examples on struts >>> files.. Thanks again. >> >> Reading the docs? >> >> http://jakarta.apache.org/struts/userGuide/building_model.html#databases >> >> Tib >> >> -- >> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: DataSource
This is from a PlugIn that has access to the ActionServlet, modify accordingly: DataSource ds = (DataSource) servlet.getServletContext().getAttribute(Globals.DATA_SOURCE_KEY); David From: Jim Bruno Goldberg <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: Struts Users Mailing List <[EMAIL PROTECTED]> Subject: Re: DataSource Date: Wed, 27 Nov 2002 17:35:54 -0200 I try this code, but I dont work because I don known where is dataSource. Can someone a .java complete (with imports)? Thanks a lot. Gemes Tibor wrote: > > 2002. november 27. 12:49 dátummal Jim Bruno Goldberg ezt írtad: > > Hi, people! > > > > Someone can send me a example class with DataSource access > > defined on > > struts-config? How can I do this? I don find any examples on struts > > files.. Thanks again. > > Reading the docs? > > http://jakarta.apache.org/struts/userGuide/building_model.html#databases > > Tib > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- CUL8R,[]s Jim Bruno Goldberg http://www.prosites.com.br -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: DataSource
I try this code, but I dont work because I don known where is dataSource. Can someone a .java complete (with imports)? Thanks a lot. Gemes Tibor wrote: > > 2002. november 27. 12:49 dátummal Jim Bruno Goldberg ezt írtad: > > Hi, people! > > > > Someone can send me a example class with DataSource access > > defined on > > struts-config? How can I do this? I don find any examples on struts > > files.. Thanks again. > > Reading the docs? > > http://jakarta.apache.org/struts/userGuide/building_model.html#databases > > Tib > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- CUL8R,[]s Jim Bruno Goldberg http://www.prosites.com.br -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: DataSource
2002. november 27. 12:49 dátummal Jim Bruno Goldberg ezt írtad: > Hi, people! > > Someone can send me a example class with DataSource access > defined on > struts-config? How can I do this? I don find any examples on struts > files.. Thanks again. Reading the docs? http://jakarta.apache.org/struts/userGuide/building_model.html#databases Tib -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
DataSource
Hi, people! Someone can send me a example class with DataSource access defined on struts-config? How can I do this? I don find any examples on struts files.. Thanks again. -- CUL8R,[]s Jim Bruno Goldberg http://www.prosites.com.br -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Utilizing the Struts DataSource from a listener
Hello: I am attempting to write information to a database using a connection obtained through a dataSource. Could anyone provide the best approach to write to a database from a session listener. I have attempted retrieving the datasource from the servlet context using the following code snippet within my session listener DataSource dataSource = (DataSource) servletContext.getAttribute(Action.DATA_SOURCE_KEY); listener cannot find the dataSource stored in the context. Help! Sincerely, Paul Idusogie Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
Re: accessing DataSource from custom tag
i think i understand now why doing sql in a custom tag would be bad. i am going to use your approach and create a utility bean that has getter methods to get the html:select option fields from the database, and add the bean to the session context. i will do this in the same Action class that creates and populates the form bean that requires those option fields. thanks. On Tue, 2002-11-05 at 07:26, [EMAIL PROTECTED] wrote: > > I'd suggest that isolating database access in Model components that are > called from the Action class is a more appropriate approach. > > What happens if you throw a SQLException in the tag or if you end up > needing to have conditional processing depending on what you bring back > from the database? You'll need conditional logic either in the tag or in > the JSP page to handle this - conditional logic that may be better managed > by the controller (Action class). > > Here's an alternative approach: > > Form POST -> > Form Bean -> > Action Class -> > Model Component (access database here) -> > Action class stores data from Model in a bean, attaches bean to > PageContext -> > JSP page retrieves data from bean using regular Struts tags > > > Circumventing this approach by performing database access in a custom tag > requires you to move Exception management and conditional processing from > your Action class into the JSP page - which then eliminates much of the > value of the MVC architecture... > > > Kevin > > --- > Kevin Bedell > Author, Struts Kick Start > > >http://www.amazon.com/exec/obidos/tg/detail/-/0672324725/qid=1036509916/sr=1-1/ref=sr_1_1/002-7047256-5912803?v=glance > > > > > > Mike Way <[EMAIL PROTECTED]> on 11/05/2002 06:04:22 AM > > Please respond to "Struts Users Mailing List" ><[EMAIL PROTECTED]> > > To:"Struts Users Mailing List" <[EMAIL PROTECTED]> > cc: (bcc: Kevin Bedell/Systems/USHO/SunLife) > Subject:Re: accessing DataSource from custom tag > > > Andrew, > > pageContext.getServletContext().getAttribute( > > > But, do you really want to do this ? > > Mike > > At 02:53 05/11/2002 -0800, you wrote: > > >is there any way to access the DataSource defined in > >struts-config.xml from within a custom tag. > > > >i usually get it from the ActionServlet context > >attribute Action.DATA_SOURCE_KEY from within an > >Action. > > > >but its not defined in the pageContext of a tag, so i > >assume its not easy to do, though i saw it mentioned, > >but not fully explained, in a thread on this list > >(Subject: RE: Urgent : Any Example which will show > > tag). > > > >my goal is to write a simple tag that downloads a list > >of countries from a database table as an ArrayList, > >adds it to the session so i can put it into an > >. if there is a better approach, please let me know. thanks, andrew. > >__ Do you Yahoo!? HotJobs > >- Search new jobs daily now http://hotjobs.yahoo.com/ -- To unsubscribe, > >e-mail: For additional commands, e-mail: > > > Mike Way, > Senior Consultant, Shared Skills Ltd > +44 (0)1752 491088, mobile +44 (0) 7941 225581 > email: [EMAIL PROTECTED] web: www.sharedskills.com > > > -- > To unsubscribe, e-mail: < > mailto:struts-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: < > mailto:struts-user-help@;jakarta.apache.org> > > > > > > > > --- > This e-mail message (including attachments, if any) is intended for the use > of the individual or entity to which it is addressed and may contain > information that is privileged, proprietary , confidential and exempt from > disclosure. If you are not the intended recipient, you are notified that > any dissemination, distribution or copying of this communication is > strictly prohibited. If you have received this communication in error, > please notify the sender and erase this e-mail message immediately. > --- > > > > -- > To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org> > > -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>