struts, hibernate, datasources .... so lost
After spending days on the net and the mailing lists I find something is just not getting through to me. I feel that what I'm doing is conceptually simple; yet I can't seem to actually implement any of it. I think I have a rudimentary understanding of how to integrate Hibernate into Struts, but I'm unsure on a few points. First the datasource. I'm trying to set up a default data source that all web applications can use. I use container based authentication and I want my realm to use it as well. Trolling these lists showed me a solution that does work with my realm (XML fragments follow below). But when I try to use that same datasource with Hibernate, my web application fails to load and I get the following error: SEVERE: Could not find datasource: java:comp/env/jdbc/prospectingDB javax.naming.NameNotFoundException: Name jdbc is not bound in this Context Here are the XML fragments from server.xml. First, I set up a global resource: GlobalNamingResources Resource name = jdbc/prospectingDB auth = Container scope = Shareable type = javax.sql.DataSource/ ResourceParams name=jdbc/prospectingDB ... Usual parameters go here Right under the engine tag I define my realm. This works for my container based auth Engine name=Catalina defaultHost=localhost debug=10 Realm className = org.apache.catalina.realm.DataSourceRealm debug = 99 dataSourceName = jdbc/prospectingDB userTable = auth_roles_view userNameCol= email userCredCol= pwd userRoleTable = auth_roles_view roleNameCol= role/ Then I set up a resource link in the default context: DefaultContext ResourceLink name = jdbc/prospectingDB global = jdbc/prospectingDB type = javax.sql.DataSource / /DefaultContext As I said, that all seems to work. But Hibernate bails: hibernate-configuration session-factory name=prospecting/hibernate/SessionFactory property name=connection.datasourcejava:comp/env/jdbc/prospectingDB/property property name=show_sqlfalse/property property name=dialectnet.sf.hibernate.dialect.PostgreSQLDialect/property mapping resource=Employee.hbm.xml/ /session-factory /hibernate-configuration I can't seem to figure out why. If I change the server.xml to define the datasource in my web-app context, then I get problems with container based authentication not finding the datasource?? ... and speaking of Hibernate, I think I figured out how to use the HibernatePlugIn. I use that to set-up a Hibernate session factory on web app instantiation. But what I'm not 100% sure on is why I need to set-up a filter to implement the open session in view pattern. One of the examples I found on the hibernate site doesn't seem to use that filter. Instead, it looks up the session factory via JNDI right in the action class. Do I have this right? Could I use either method to grab a Hibernate session? If I extend the action class to do the JNDI look-up (so I only need to write the lookup code once), would either method provide a benefit over the other? I'm at a point where I feel like I have enough knowledge to build an app, but at the same time I don't really understand the technology. That's kind of precarious - I'm afraid I'm going to leave sessions open ... or something else that will cause errors and be hard to track down. Thank in advance for any advice! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts, hibernate, datasources .... so lost
Rich I know how you feel. I just dealt with nearly the same problems the other day. I for the life of me could not get Hibernate to bind to my JNDI datasource.. so I bailed on that and in my hibernate.cfg.xml I just had it setup the datasource and manage it from there: hibernate-configuration session-factory name=salesweb:/hibernate/SessionFactory property name=dialectnet.sf.hibernate.dialect.MySQLDialect/property property name=show_sqltrue/property property name=connection.usernameuser/property property name=connection.passwordpass/property property name=connection.urljdbc:mysql://192.168.0.104:3306/salesweb/property property name=connection.driver_classcom.mysql.jdbc.Driver/property property name=use_outer_jointrue/property property name=transaction.factory_classnet.sf.hibernate.transaction.JDBCTransactio nFactory/property property name=dbcp.minIdle1/property /session-factory /hibernate-configuration etc. So what hibernate does when you build its config is load up a JNDI name and bind its session to that at salesweb:/hibernate/SessionFactory. Then I am using the hibernateFilter which the first run through will build that config and also store a static instance of the factory within that class. The reason its important to use the filter (to my understanding) is this: User requests a webpage, goes to struts action, action calls getSession() from the hibernatefilter, it binds that session to the current executing thread and ships it to the action. Action loads the requested items, perhaps the item has a collection that is loaded lazily, so it doesnt actually get loaded in the action. Action finishes and forwards to view (Note this is in the same thread!!), the view is a jsp that wants to render that lazily loaded collection. Well if you closed the session in your action this would fail. but because the session is still maintained until the request is fully finished it succeeds. Make sense? Anyway thats my understanding, I could be flawed =) Good luck! -David - Original Message - From: Rich Garabedian [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 19, 2003 7:35 AM Subject: struts, hibernate, datasources so lost After spending days on the net and the mailing lists I find something is just not getting through to me. I feel that what I'm doing is conceptually simple; yet I can't seem to actually implement any of it. I think I have a rudimentary understanding of how to integrate Hibernate into Struts, but I'm unsure on a few points. First the datasource. I'm trying to set up a default data source that all web applications can use. I use container based authentication and I want my realm to use it as well. Trolling these lists showed me a solution that does work with my realm (XML fragments follow below). But when I try to use that same datasource with Hibernate, my web application fails to load and I get the following error: SEVERE: Could not find datasource: java:comp/env/jdbc/prospectingDB javax.naming.NameNotFoundException: Name jdbc is not bound in this Context Here are the XML fragments from server.xml. First, I set up a global resource: GlobalNamingResources Resource name = jdbc/prospectingDB auth = Container scope = Shareable type = javax.sql.DataSource/ ResourceParams name=jdbc/prospectingDB ... Usual parameters go here Right under the engine tag I define my realm. This works for my container based auth Engine name=Catalina defaultHost=localhost debug=10 Realm className = org.apache.catalina.realm.DataSourceRealm debug = 99 dataSourceName = jdbc/prospectingDB userTable = auth_roles_view userNameCol= email userCredCol= pwd userRoleTable = auth_roles_view roleNameCol= role/ Then I set up a resource link in the default context: DefaultContext ResourceLink name = jdbc/prospectingDB global = jdbc/prospectingDB type = javax.sql.DataSource / /DefaultContext As I said, that all seems to work. But Hibernate bails: hibernate-configuration session-factory name=prospecting/hibernate/SessionFactory property name=connection.datasourcejava:comp/env/jdbc/prospectingDB/property property name=show_sqlfalse/property property name=dialectnet.sf.hibernate.dialect.PostgreSQLDialect/property mapping resource=Employee.hbm.xml/ /session-factory /hibernate-configuration I can't seem to figure out why. If I change the server.xml to define the datasource in my web-app context, then I get problems with container based authentication not finding the datasource?? ... and speaking of Hibernate, I think I figured out how to use the HibernatePlugIn. I use that to set-up a Hibernate session factory on web app instantiation. But what I'm not 100% sure on is why I need to set-up a filter to implement the open session in view pattern. One of the examples I
Re: struts, hibernate, datasources .... so lost
Rich, Ya the binding thing with JNDI and tomcat is messed up.. for some reason I've read its Read Only.. but the strange thing is I WAS able to get it working when I bound to that resource from a static class, but as soon as I used a filter or a struts plugin it no longer worked.. really lame. Regarding what happens after you load something from Hibernate. I'm still learning this myself, but I assume if you don't load ANYTHING lazily then you should be able to do anything with that variable and have no worries. However if you have an object that contains say a set of other objects, ie a team with a set of players, and set it to lazy loading, meaning when you load team 1, the players arent loaded until you call, getPlayers(), then at that point hibernate is still bound to your variable and will load that from the db assuming the session you initially loaded the team with is still open. Make sense? The way it works is hibernate has its own classes inherited from set/list/map etc that handle that.. and it uses those when you load sets. -David - Original Message - From: Rich Garabedian [EMAIL PROTECTED] To: 'David Erickson' [EMAIL PROTECTED] Sent: Friday, December 19, 2003 11:12 AM Subject: RE: struts, hibernate, datasources so lost David, David, thanks so much for your note. I guess I'll try having Hibernate setup the datasource if I can't get it to work they way I'm trying now. Doing that really bothers me though. I thought datasources were supposed to allow us to configure a single point of entry and then just use the logical name everywhere ... and not to have to worry about anything else. Need to change your database? Just look in one location and change - easy as pie. Yeah, right. Configuring a JDBC realm for authentication, and then a datasource in an entirely different file just seems plain backwards to me. Grrrh. Sorry, I'm really frustrated right now. I spent hours trying to determine why my web app was crashing on load. Come to find out, ehcache.jar is required (at least it seems to be for me). Even though the hibernate lib/readme says it's optional. (I can't find anywhere where I specify cache useage). The explanation below helps clear things up, but there still is one thing I really don't understand. If, in my action, I use hibernate to grab something from the data layer and store it in a local variable ... don't I know hold that data in my hands. If the session closes now, then who cares? I've already copied it into a local variable and can do what I please with it. Right? Dunno, I'm sure that last question readily shows my ignorance of how the entire processes works :-) -Original Message- From: David Erickson [mailto:[EMAIL PROTECTED] Sent: Friday, December 19, 2003 1:00 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: struts, hibernate, datasources so lost Rich I know how you feel. I just dealt with nearly the same problems the other day. I for the life of me could not get Hibernate to bind to my JNDI datasource.. so I bailed on that and in my hibernate.cfg.xml I just had it setup the datasource and manage it from there: hibernate-configuration session-factory name=salesweb:/hibernate/SessionFactory property name=dialectnet.sf.hibernate.dialect.MySQLDialect/property property name=show_sqltrue/property property name=connection.usernameuser/property property name=connection.passwordpass/property property name=connection.urljdbc:mysql://192.168.0.104:3306/salesweb/property property name=connection.driver_classcom.mysql.jdbc.Driver/property property name=use_outer_jointrue/property property name=transaction.factory_classnet.sf.hibernate.transaction.JDBCTransa ct io nFactory/property property name=dbcp.minIdle1/property /session-factory /hibernate-configuration etc. So what hibernate does when you build its config is load up a JNDI name and bind its session to that at salesweb:/hibernate/SessionFactory. Then I am using the hibernateFilter which the first run through will build that config and also store a static instance of the factory within that class. The reason its important to use the filter (to my understanding) is this: User requests a webpage, goes to struts action, action calls getSession() from the hibernatefilter, it binds that session to the current executing thread and ships it to the action. Action loads the requested items, perhaps the item has a collection that is loaded lazily, so it doesnt actually get loaded in the action. Action finishes and forwards to view (Note this is in the same thread!!), the view is a jsp that wants to render that lazily loaded collection. Well if you closed the session in your action this would fail. but because the session is still maintained until the request is fully finished it succeeds. Make sense? Anyway thats my
RE: struts, hibernate, datasources .... so lost
I think that makes sense. So basically you are saying I HAVE to implement the filter and doing something like this: try { Context ctx = new InitialContext(); SessionFactory sf = (SessionFactory)ctx.lookup(prospecting/hibernate/SessionFactory); Session session = sf.openSession(); Query query = session.createQuery(select e.pwd from com.autorevenue.prospecting.hibernate.Employee e where e.email = :email); query.setString(email, email); e = (Employee)query.uniqueResult(); if( e != null) { password = e.getPwd(); } session.close(); } catch(Exception exc) { servlet.log(Hibernate error + exc.getMessage()); } Won't work?? I've made some progress, I think. Log output shows Hibernate is returning a value for a given query but the code above keeps throwing an exception that is simply Hibernate error null Perhaps I'm getting that because I'm not using the filter yet? Another frustrating thing is that my container based auth stopped working. Keep getting Name jdbc is not bound in this Context. Have to play with that some more. Another weird thing. Copying a new war to the war directory and having Tomcat reload my war doesn't seem to work anymore. I mean, it does load, but when it does changes to the Hibernate config aren't updated. Only way, so far, to see changes has been to shutdown server, deleted war filed and war directory, copy new war file to webapp directory, and restart. Does the same thing happen to anyone else? -Original Message- From: David Erickson [mailto:[EMAIL PROTECTED] Sent: Friday, December 19, 2003 1:31 PM To: [EMAIL PROTECTED] Subject: Re: struts, hibernate, datasources so lost Rich, Ya the binding thing with JNDI and tomcat is messed up.. for some reason I've read its Read Only.. but the strange thing is I WAS able to get it working when I bound to that resource from a static class, but as soon as I used a filter or a struts plugin it no longer worked.. really lame. Regarding what happens after you load something from Hibernate. I'm still learning this myself, but I assume if you don't load ANYTHING lazily then you should be able to do anything with that variable and have no worries. However if you have an object that contains say a set of other objects, ie a team with a set of players, and set it to lazy loading, meaning when you load team 1, the players arent loaded until you call, getPlayers(), then at that point hibernate is still bound to your variable and will load that from the db assuming the session you initially loaded the team with is still open. Make sense? The way it works is hibernate has its own classes inherited from set/list/map etc that handle that.. and it uses those when you load sets. -David - Original Message - From: Rich Garabedian [EMAIL PROTECTED] To: 'David Erickson' [EMAIL PROTECTED] Sent: Friday, December 19, 2003 11:12 AM Subject: RE: struts, hibernate, datasources so lost David, David, thanks so much for your note. I guess I'll try having Hibernate setup the datasource if I can't get it to work they way I'm trying now. Doing that really bothers me though. I thought datasources were supposed to allow us to configure a single point of entry and then just use the logical name everywhere ... and not to have to worry about anything else. Need to change your database? Just look in one location and change - easy as pie. Yeah, right. Configuring a JDBC realm for authentication, and then a datasource in an entirely different file just seems plain backwards to me. Grrrh. Sorry, I'm really frustrated right now. I spent hours trying to determine why my web app was crashing on load. Come to find out, ehcache.jar is required (at least it seems to be for me). Even though the hibernate lib/readme says it's optional. (I can't find anywhere where I specify cache useage). The explanation below helps clear things up, but there still is one thing I really don't understand. If, in my action, I use hibernate to grab something from the data layer and store it in a local variable ... don't I know hold that data in my hands. If the session closes now, then who cares? I've already copied it into a local variable and can do what I please with it. Right? Dunno, I'm sure that last question readily shows my ignorance of how the entire processes works :-) -Original Message- From: David Erickson [mailto:[EMAIL PROTECTED] Sent: Friday, December 19, 2003 1:00 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: Re: struts, hibernate, datasources so lost Rich I know how you feel. I just dealt with nearly the same problems the other day. I for the life of me could not get Hibernate to bind to my JNDI datasource.. so I bailed on that and in my hibernate.cfg.xml I just had it setup the datasource and manage it from there: hibernate-configuration
Re[2]: struts, hibernate, datasources .... so lost
DE Regarding what happens after you load something from Hibernate. I'm still DE learning this myself, but I assume if you don't load ANYTHING lazily then DE you should be able to do anything with that variable and have no worries. DE However if you have an object that contains say a set of other objects, ie a DE team with a set of players, and set it to lazy loading, meaning when you DE load team 1, the players arent loaded until you call, getPlayers(), then at DE that point hibernate is still bound to your variable and will load that from DE the db assuming the session you initially loaded the team with is still DE open. Make sense? The way it works is hibernate has its own classes DE inherited from set/list/map etc that handle that.. and it uses those when DE you load sets. Yes, makes sense. But there is a way you can close the Hibernate Session before forwarding to the JSP, if you explicitly initialize all objects that you need in the view with Hibernate.initialize() before closing the session. Jens www.oregano-server.org - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts, hibernate, datasources .... so lost
That code should work assuming your object is fully loaded by the time it gets to the view and no longer needs the session. Also I would use Transactions in your code even on simple query's.. that was the advice given on hibernate's site. ie: Transaction tx = session.beginTransaction(). then tx.commit() when done or rollback or whatever. Also I don't know what you are using as your log manager but using log4j when I get a hibernate error I also send it the exception and it prints a stack trace for me which gives more information on what went wrong. Can't say that I've seen that behavior with tomcat myself =).. I have a whole other can of worms I've had to deal with involving that... -David - Original Message - From: Rich Garabedian [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Friday, December 19, 2003 2:10 PM Subject: RE: struts, hibernate, datasources so lost I think that makes sense. So basically you are saying I HAVE to implement the filter and doing something like this: try { Context ctx = new InitialContext(); SessionFactory sf = (SessionFactory)ctx.lookup(prospecting/hibernate/SessionFactory); Session session = sf.openSession(); Query query = session.createQuery(select e.pwd from com.autorevenue.prospecting.hibernate.Employee e where e.email = :email); query.setString(email, email); e = (Employee)query.uniqueResult(); if( e != null) { password = e.getPwd(); } session.close(); } catch(Exception exc) { servlet.log(Hibernate error + exc.getMessage()); } Won't work?? I've made some progress, I think. Log output shows Hibernate is returning a value for a given query but the code above keeps throwing an exception that is simply Hibernate error null Perhaps I'm getting that because I'm not using the filter yet? Another frustrating thing is that my container based auth stopped working. Keep getting Name jdbc is not bound in this Context. Have to play with that some more. Another weird thing. Copying a new war to the war directory and having Tomcat reload my war doesn't seem to work anymore. I mean, it does load, but when it does changes to the Hibernate config aren't updated. Only way, so far, to see changes has been to shutdown server, deleted war filed and war directory, copy new war file to webapp directory, and restart. Does the same thing happen to anyone else? -Original Message- From: David Erickson [mailto:[EMAIL PROTECTED] Sent: Friday, December 19, 2003 1:31 PM To: [EMAIL PROTECTED] Subject: Re: struts, hibernate, datasources so lost Rich, Ya the binding thing with JNDI and tomcat is messed up.. for some reason I've read its Read Only.. but the strange thing is I WAS able to get it working when I bound to that resource from a static class, but as soon as I used a filter or a struts plugin it no longer worked.. really lame. Regarding what happens after you load something from Hibernate. I'm still learning this myself, but I assume if you don't load ANYTHING lazily then you should be able to do anything with that variable and have no worries. However if you have an object that contains say a set of other objects, ie a team with a set of players, and set it to lazy loading, meaning when you load team 1, the players arent loaded until you call, getPlayers(), then at that point hibernate is still bound to your variable and will load that from the db assuming the session you initially loaded the team with is still open. Make sense? The way it works is hibernate has its own classes inherited from set/list/map etc that handle that.. and it uses those when you load sets. -David - Original Message - From: Rich Garabedian [EMAIL PROTECTED] To: 'David Erickson' [EMAIL PROTECTED] Sent: Friday, December 19, 2003 11:12 AM Subject: RE: struts, hibernate, datasources so lost David, David, thanks so much for your note. I guess I'll try having Hibernate setup the datasource if I can't get it to work they way I'm trying now. Doing that really bothers me though. I thought datasources were supposed to allow us to configure a single point of entry and then just use the logical name everywhere ... and not to have to worry about anything else. Need to change your database? Just look in one location and change - easy as pie. Yeah, right. Configuring a JDBC realm for authentication, and then a datasource in an entirely different file just seems plain backwards to me. Grrrh. Sorry, I'm really frustrated right now. I spent hours trying to determine why my web app was crashing on load. Come to find out, ehcache.jar is required (at least it seems to be for me). Even though the hibernate lib/readme says it's optional. (I can't find anywhere where I specify cache useage). The explanation below
datasources and oracle 9i
hi, i am using Oracle 9i as my datasource and have declared it in my struts-config as follows: data-source key=DB type=oracle.jdbc.pool.OracleConnectionPoolDataSource set-property property=autoCommit value=false/ set-property property=description value=DB_Connection_Pool/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=5/ set-property property=minCount value=1/ set-property property=password value=password/ set-property property=url value=jdbc:oracle:thin:@ip-of-server:1521:ORACLE1/ set-property property=user value=user/ /data-source however, when i come to use this datasource in my struts actions, it gives me the following error: Invalid Oracle URL specified: OracleDataSource.makeURL im accessing the datasource in my actions like so (i use the same thing with an SQLServer datasource and it works fine): DataSource dataSource = (DataSource)servlet.getServletContext().getAttribute(DB); also, i have my oracle driver jar in the commons folder in tomcat - could this be the cause Any help would be much appreciated! claire
Datasources Tomcat/Struts
Hello, next to my question about deprecation, i've try to make Tomcat JNDI Datasource working without success... I followed the How-to but nothing goes well. My configuration is : - Tomcat 4.1.27 - JDK 1.4.2 - Struts 1.1 - MySQL 4 When i try to make a request on the database i've got : Cannot load JDBC driver class 'null' this error come from the line : Connection conn = ds.getConnection(); (Code is a copy and paste from the how to) I think that tomcat cannot found the JDBC drivers. My jars ( commons-collections, common-dbcp, common-pool, mm.mysql) are in the CATALINA_HOME/common/lib
Re: Datasources Tomcat/Struts
Hi Mathieu Grimault, can you send me ur tomcat's server.xml file, the problem is in tomcat configuration, Regards, viru - Original Message - From: Mathieu Grimault [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, October 28, 2003 5:01 PM Subject: Datasources Tomcat/Struts Hello, next to my question about deprecation, i've try to make Tomcat JNDI Datasource working without success... I followed the How-to but nothing goes well. My configuration is : - Tomcat 4.1.27 - JDK 1.4.2 - Struts 1.1 - MySQL 4 When i try to make a request on the database i've got : Cannot load JDBC driver class 'null' this error come from the line : Connection conn = ds.getConnection(); (Code is a copy and paste from the how to) I think that tomcat cannot found the JDBC drivers. My jars ( commons-collections, common-dbcp, common-pool, mm.mysql) are in the CATALINA_HOME/common/lib - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts 1.1:Multiple DataSources
Using struts 1.1 with SQL2000 Database. Defined two data sources in my strust-conf.xml: data-sources data-source set-property property=key value=one / ... ... /data-source data-source set-property property=key value=two / ... ... /data-source /data-sources From with in my action classes dataSource = getDataSource(request,one); or/ dataSource = getDataSource(request,two); both of these throw a null pointer exception. However both work fine with getDataSource(request) when I define only one datasource and don't pass in the key. Does anyone have a solution or a reference web site? thanks in Advance John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: struts 1.1:Multiple DataSources
John, read the posts on Connection Pool. I've got it working in 1.0.2 by setting the key as an Attribute of the datasource tag not as a property. struts-config file: data-source key=one ... ... /data-source data-source set-property property=key value=two / ... ... /data-source Now in the Action Class: ServletContext context = servlet.getServletContext(); DataSource dataSource = (DataSource)context.getAttribute(one); OR you can cast it as a GenericDataSource to print out its properites: ServletContext context = servlet.getServletContext(); org.apache.struts.util.GenericDataSource genSource = (org.apache.struts.util.GenericDataSource)context.getAttribute(one); System.out.println(genSource.getDescription()); System.out.println(genSource.getDriverClass()); System.out.println(genSource.getUrl()); This works for Struts 1.0.2. Not sure if it will work with any other version. Thanks to Dennis Lee and David Graham!! -Original Message- From: John Wilson [mailto:[EMAIL PROTECTED] Sent: March 20, 2003 3:54 AM To: '[EMAIL PROTECTED]' Subject: struts 1.1:Multiple DataSources Using struts 1.1 with SQL2000 Database. Defined two data sources in my strust-conf.xml: data-sources data-source set-property property=key value=one / ... ... /data-source data-source set-property property=key value=two / ... ... /data-source /data-sources From with in my action classes dataSource = getDataSource(request,one); or/ dataSource = getDataSource(request,two); both of these throw a null pointer exception. However both work fine with getDataSource(request) when I define only one datasource and don't pass in the key. Does anyone have a solution or a reference web site? thanks in Advance John - 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]
Tomcat 4.1.18, DBCP, DataSources - What are people using?
After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david-
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david-
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
I'm working fine with: Tomcat 4.1.18 (+ DBCP Connection Pool) Struts 1.1-rc1 Oracle 9i Servers: Win2K, Red Hat 8, Solaris 8 What's the bug you're referring too? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 2:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
I'm setting up named data sources with the following: data-sources data-source key=eha type=org.apache.commons.dbcp.BasicDataSource set-property property=autoCommit value=false/ set-property property=description value=EHA Definition/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=url value=jdbc:oracle:thin:@citation:1521/citation/ set-property property=user value=david/ set-property property=password value=secret/ /data-source /data-sources In my Action, I reference this as: DataSource ds = getDataSource(req, eha); Tomcat reports the following in catalina.out: SQLException: Cannot load JDBC driver class 'null' -david- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
Make sure commons-dbcp and pooling are not in your common/lib, use tomcat's. Besides, I don't use struts datasource, I use Tomcat JNDI datasource and pooling. Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 5:12 PM To: 'Struts Users Mailing List' Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? I'm setting up named data sources with the following: data-sources data-source key=eha type=org.apache.commons.dbcp.BasicDataSource set-property property=autoCommit value=false/ set-property property=description value=EHA Definition/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=url value=jdbc:oracle:thin:@citation:1521/citation/ set-property property=user value=david/ set-property property=password value=secret/ /data-source /data-sources In my Action, I reference this as: DataSource ds = getDataSource(req, eha); Tomcat reports the following in catalina.out: SQLException: Cannot load JDBC driver class 'null' -david- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
I use Tomcat's JNDI database, not struts - my config is below. Make sure that classes12.jar is in common/lib. Matt web.xml resource-ref descriptionDB Connection/description res-ref-namejdbc/mydb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref webapps/mycontext.xml Resource name=jdbc/mydb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/mydb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter !-- Maximum number of dB connections in pool. Set to 0 for no limit. -- parameter namemaxActive/name value50/value /parameter !-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. -- parameter namemaxIdle/name value10/value /parameter !-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. -- parameter namemaxWait/name value1/value /parameter !-- Database username and password for connections -- parameter nameusername/name valueusername/value /parameter parameter namepassword/name valuepassword/value /parameter !-- Class name for Oracle JDBC driver -- parameter namedriverClassName/name valueoracle.jdbc.pool.OracleConnectionPoolDataSource/value /parameter !-- The JDBC connection url for connecting to your db. -- parameter nameurl/name valuejdbc:oracle:thin:@hostname:1521:SID/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namevalidationQuery/name valueSELECT 1 FROM DUAL/value /parameter /ResourceParams -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? Make sure commons-dbcp and pooling are not in your common/lib, use tomcat's. Besides, I don't use struts datasource, I use Tomcat JNDI datasource and pooling. Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 5:12 PM To: 'Struts Users Mailing List' Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? I'm setting up named data sources with the following: data-sources data-source key=eha type=org.apache.commons.dbcp.BasicDataSource set-property property=autoCommit value=false/ set-property property=description value=EHA Definition/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=url value=jdbc:oracle:thin:@citation:1521/citation/ set-property property=user value=david/ set-property property=password value=secret/ /data-source /data-sources In my Action, I reference this as: DataSource ds = getDataSource(req, eha); Tomcat reports the following in catalina.out: SQLException: Cannot load JDBC driver class 'null' -david- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
Sorry, make sure top use commons-dbcp and pooling in tomcat's common/lib. Since Tomcat JNDI is tomcat's not struts'. Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: Raible, Matt [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 5:24 PM To: 'Struts Users Mailing List' Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? I use Tomcat's JNDI database, not struts - my config is below. Make sure that classes12.jar is in common/lib. Matt web.xml resource-ref descriptionDB Connection/description res-ref-namejdbc/mydb/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref webapps/mycontext.xml Resource name=jdbc/mydb auth=Container type=javax.sql.DataSource/ ResourceParams name=jdbc/mydb parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter !-- Maximum number of dB connections in pool. Set to 0 for no limit. -- parameter namemaxActive/name value50/value /parameter !-- Maximum number of idle dB connections to retain in pool. Set to 0 for no limit. -- parameter namemaxIdle/name value10/value /parameter !-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. -- parameter namemaxWait/name value1/value /parameter !-- Database username and password for connections -- parameter nameusername/name valueusername/value /parameter parameter namepassword/name valuepassword/value /parameter !-- Class name for Oracle JDBC driver -- parameter namedriverClassName/name valueoracle.jdbc.pool.OracleConnectionPoolDataSource/value /parameter !-- The JDBC connection url for connecting to your db. -- parameter nameurl/name valuejdbc:oracle:thin:@hostname:1521:SID/value /parameter parameter nameremoveAbandoned/name valuetrue/value /parameter parameter nameremoveAbandonedTimeout/name value60/value /parameter parameter namelogAbandoned/name valuetrue/value /parameter parameter namevalidationQuery/name valueSELECT 1 FROM DUAL/value /parameter /ResourceParams -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 3:15 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? Make sure commons-dbcp and pooling are not in your common/lib, use tomcat's. Besides, I don't use struts datasource, I use Tomcat JNDI datasource and pooling. Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 5:12 PM To: 'Struts Users Mailing List' Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? I'm setting up named data sources with the following: data-sources data-source key=eha type=org.apache.commons.dbcp.BasicDataSource set-property property=autoCommit value=false/ set-property property=description value=EHA Definition/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=url value=jdbc:oracle:thin:@citation:1521/citation/ set-property property=user value=david/ set-property property=password value=secret/ /data-source /data-sources In my Action, I reference this as: DataSource ds = getDataSource(req, eha); Tomcat reports the following in catalina.out: SQLException: Cannot load JDBC driver class 'null' -david- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows
Re: Tomcat 4.1.18, DBCP, DataSources - What are people using?
My DAO's DBCP-standalone works with Tomcat; and you can switch to JNDI pool. Source: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/basicportal/src/basicWebLib/org/apache/basicWebLib/DAO/BasicDAOImpl.java .V David Haynes wrote: After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tomcat 4.1.18, DBCP, DataSources - What are people using?
I'm using Jboss connection pooling and access it from a session bean. Marco -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 10:12 PM To: 'Struts Users Mailing List' Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? I'm setting up named data sources with the following: data-sources data-source key=eha type=org.apache.commons.dbcp.BasicDataSource set-property property=autoCommit value=false/ set-property property=description value=EHA Definition/ set-property property=driverClass value=oracle.jdbc.driver.OracleDriver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=url value=jdbc:oracle:thin:@citation:1521/citation/ set-property property=user value=david/ set-property property=password value=secret/ /data-source /data-sources In my Action, I reference this as: DataSource ds = getDataSource(req, eha); Tomcat reports the following in catalina.out: SQLException: Cannot load JDBC driver class 'null' -david- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:55 PM To: [EMAIL PROTECTED] Subject: RE: Tomcat 4.1.18, DBCP, DataSources - What are people using? What is the bug that you discovered? Mine works just fine. Tomcat 4.1.18 Struts 1.1-rc1 Oracle 8i Regards, PQ This Guy Thinks He Knows Everything This Guy Thinks He Knows What He Is Doing -Original Message- From: David Haynes [mailto:[EMAIL PROTECTED] Sent: February 26, 2003 4:43 PM To: [EMAIL PROTECTED] Subject: Tomcat 4.1.18, DBCP, DataSources - What are people using? After working on this for most of the day, I have discovered that Tomcat 4.1.18 and DBCP do not play well together. There is a bug against Tomcat for this (I have *got* to remember to check the bugs databases sooner ;-) ), but no analysis or corrective action has been recorded to date. So, my question is this. What are people using for their DataSource? My environment is: Tomcat 4.1.18 Struts 1.1rc1 Oracle 9i JDBC Thanks! -david- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
dataSources outside of actionservlet
hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
FW: dataSources outside of actionservlet
Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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]
Re: FW: dataSources outside of actionservlet
The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
FW: dataSources outside of actionservlet
I'm really sorry to post this mail again,, but is there something i'm not understanding ? Or does everyone do all their queries in action servlets? I can see how what i'm trying could be wrong in that, if i want to reuse my non servlet classes using the datasource in config.xml might render this webappliction-specific. But then again it is also true that using the settings in the config file has a certain appeal especially if one is looking at supporting more than one db vendor. I understand that perhaps i need to have a pool of connections, but i want to leave this stuff as an optimisation rather than a means of getting to the settings in config.xml. -- here's my original message-- hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. -- many thanks in advance mark Many thanks in advance mark -- Forwarded Message From: Mark [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 11:18:25 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: FW: dataSources outside of actionservlet Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- End of Forwarded Message -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dataSources outside of actionservlet
Woohoo!!! But you'll have to forgive my ignorance, but any chance of a more ostensive answer, like an example for example.. So something like DataSource ds = getDatasource(mykey); (MyBEan).doSomething(ds, and other args); Is this along the right lines? Many thanks mark On 17-12-2002 15:05, Matthias Bauer [EMAIL PROTECTED] wrote: The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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: FW: dataSources outside of actionservlet
Using the command design pattern you can ensure the DB code needs to be coded only once. See the example below http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24579.html --- Matthias Bauer [EMAIL PROTECTED] wrote: The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: FW: dataSources outside of actionservlet
Hi mark, It is a good question! I've not used them so far but i think the new java Properties class is designed to supply config. info to a system. If you have a command processor class that gets the connection maybe you should make it's name a property so you can have a different class in the web env. from other env? hth - I'n not n expert on this stuff - just in case no=one else replies! K. --- Mark [EMAIL PROTECTED] wrote: I'm really sorry to post this mail again,, but is there something i'm not understanding ? Or does everyone do all their queries in action servlets? I can see how what i'm trying could be wrong in that, if i want to reuse my non servlet classes using the datasource in config.xml might render this webappliction-specific. But then again it is also true that using the settings in the config file has a certain appeal especially if one is looking at supporting more than one db vendor. I understand that perhaps i need to have a pool of connections, but i want to leave this stuff as an optimisation rather than a means of getting to the settings in config.xml. -- here's my original message-- hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. -- many thanks in advance mark Many thanks in advance mark -- Forwarded Message From: Mark [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 11:18:25 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: FW: dataSources outside of actionservlet Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- End of Forwarded Message -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dataSources outside of actionservlet
Thanks keith that looks like a really good elegant way of doing this, but as i conceded before I particularly stupid, and i don't get it. To be honest I've always had the db pooling stuff taken care for me before which was only of the attractions of using struts.. Is there no means to referencing to setting in config.xml. Like an example that explains the following Stuff_to_get_to_the_stuff_configxml.getDatasource(mykey); Or am i trying to make my life too simple and really should give up development and become a dustman or something? Many thanks again mark On 17-12-2002 15:12, keithBacon [EMAIL PROTECTED] wrote: Using the command design pattern you can ensure the DB code needs to be coded only once. See the example below http://www.mail-archive.com/struts-user@jakarta.apache.org/msg24579.html --- Matthias Bauer [EMAIL PROTECTED] wrote: The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] = ~~ Search the archive:- http://www.mail-archive.com/struts-user%40jakarta.apache.org/ ~~ Keith Bacon - Looking for struts work - South-East UK. phone UK 07960 011275 __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- 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: FW: dataSources outside of actionservlet
Another option is to aquire the database connection via jndi when you need it. Edgar -Original Message- From: Matthias Bauer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 9:05 AM To: 'Struts Users Mailing List' Subject: Re: FW: dataSources outside of actionservlet The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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: dataSources outside of actionservlet
I know that , i've read that .. But I what i really want to know is this Without importing any servlet stuff Some_means_of_getting_to_details_in_config_xml.getDatasource(mykey); Many thanks mark On 17-12-2002 15:17, Edgar P. Dollin [EMAIL PROTECTED] wrote: Another option is to aquire the database connection via jndi when you need it. Edgar -Original Message- From: Matthias Bauer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 9:05 AM To: 'Struts Users Mailing List' Subject: Re: FW: dataSources outside of actionservlet The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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: dataSources outside of actionservlet
Context env = (Context) new InitialContext().lookup(java:comp/env); DataSource ds = (DataSource) env.lookup(yourconnection); conn = ds.getConnection(); Edgar -Original Message- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 10:13 AM To: Struts Users Mailing List Subject: Re: dataSources outside of actionservlet I know that , i've read that .. But I what i really want to know is this Without importing any servlet stuff Some_means_of_getting_to_details_in_config_xml.getDatasource(mykey); Many thanks mark On 17-12-2002 15:17, Edgar P. Dollin [EMAIL PROTECTED] wrote: Another option is to aquire the database connection via jndi when you need it. Edgar -Original Message- From: Matthias Bauer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 9:05 AM To: 'Struts Users Mailing List' Subject: Re: FW: dataSources outside of actionservlet The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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: dataSources outside of actionservlet
Thanks edgar.. For those folks who are starting out or don't read binary Context and InitialContext are part of the javax.naming package So you'll need to import javax.naming.Context; import javax.naming.InitialContext; The javadocs are less cryptic.. Sometimes is just knowing which ones one has to read.. Many thanks again mark On 17-12-2002 17:18, Edgar P. Dollin [EMAIL PROTECTED] wrote: Context env = (Context) new InitialContext().lookup(java:comp/env); DataSource ds = (DataSource) env.lookup(yourconnection); conn = ds.getConnection(); Edgar -Original Message- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 10:13 AM To: Struts Users Mailing List Subject: Re: dataSources outside of actionservlet I know that , i've read that .. But I what i really want to know is this Without importing any servlet stuff Some_means_of_getting_to_details_in_config_xml.getDatasource(mykey); Many thanks mark On 17-12-2002 15:17, Edgar P. Dollin [EMAIL PROTECTED] wrote: Another option is to aquire the database connection via jndi when you need it. Edgar -Original Message- From: Matthias Bauer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 9:05 AM To: 'Struts Users Mailing List' Subject: Re: FW: dataSources outside of actionservlet The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dataSources outside of actionservlet
Okay.. We're almost there, but the env.lookup(yourconnection) bit is the key that is specified in config.xml 'right?' data-source key=yourconnection Doesn't work like this it throws an exception It tells be yourname is not bound in this context... While I'm sure , in fact i know there's a good reason for this, I usually prefer to enrich my understanding after something is running Prehaps i should try denistry rather than becoming a dustman.. Many thanks mark On 17-12-2002 17:45, Mark [EMAIL PROTECTED] wrote: Thanks edgar.. For those folks who are starting out or don't read binary Context and InitialContext are part of the javax.naming package So you'll need to import javax.naming.Context; import javax.naming.InitialContext; The javadocs are less cryptic.. Sometimes is just knowing which ones one has to read.. Many thanks again mark On 17-12-2002 17:18, Edgar P. Dollin [EMAIL PROTECTED] wrote: Context env = (Context) new InitialContext().lookup(java:comp/env); DataSource ds = (DataSource) env.lookup(yourconnection); conn = ds.getConnection(); Edgar -Original Message- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 10:13 AM To: Struts Users Mailing List Subject: Re: dataSources outside of actionservlet I know that , i've read that .. But I what i really want to know is this Without importing any servlet stuff Some_means_of_getting_to_details_in_config_xml.getDatasource(mykey); Many thanks mark On 17-12-2002 15:17, Edgar P. Dollin [EMAIL PROTECTED] wrote: Another option is to aquire the database connection via jndi when you need it. Edgar -Original Message- From: Matthias Bauer [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 17, 2002 9:05 AM To: 'Struts Users Mailing List' Subject: Re: FW: dataSources outside of actionservlet The normal thing to is the following: You aquire a database connection in the action class and pass it on as a parameter to the bean's database methods. --- Matthias Mark wrote: Sorry to repost this question, but the more i think about it the more i think it a reasonable one (please tell me if i'm wrong). -- Forwarded Message From: Mark Lowe [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] Date: Tue, 17 Dec 2002 09:03:33 +0100 To: Struts Users Mailing List [EMAIL PROTECTED] Subject: dataSources outside of actionservlet hello you'll all have to forgive my stupidity but i've been having real problems trying to reference the datasource specified in config.xml in my business logic classes. I've been very good and seperated everything as one should. but i really need a straight answer to this (i.e. an example that works). For maximum code re-use, business logic beans should be designed and implemented so that they do not know they are being executed in a web application environment now i've only seen examples referencing the datasource inside an action servlet, this appears to go against the design pattern. So how do i do this? have i neglected to find the correct example? why are all the examples of how to reference the datasource breaking the aforementioned priciple? please i'm very confused .. many thanks in advance mark -- 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] -- 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] -- 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: dataSources outside of actionservlet
On Tue, 17 Dec 2002 17:45, Mark [EMAIL PROTECTED] wrote: Thanks edgar.. For those folks who are starting out or don't read binary Context and InitialContext are part of the javax.naming package So you'll need to import javax.naming.Context; import javax.naming.InitialContext; The javadocs are less cryptic.. Sometimes is just knowing which ones one has to read.. Many thanks again mark On 17-12-2002 17:18, Edgar P. Dollin [EMAIL PROTECTED] wrote: Context env = (Context) new InitialContext().lookup(java:comp/env); DataSource ds = (DataSource) env.lookup(yourconnection); conn = ds.getConnection(); Here's another way to do it without using JNDI: Given a stuts-config.xml file with a datasource like this: data-sources data-source key=myDatabase type=org.apache.struts.util.GenericDataSource set-property property=url value= ... / ... /data-source /data-sources You can access a database connection in your Action like this: Connection dbCon = null; ServletContext context = servlet.getServletContext(); DataSource ds = (DataSource) context.getAttribute(myDatabase); try{ dbCon = ds.getConnection(); ... Now at this point you want to use a model or business object that handles that actual logic. For example, suppose we have a Product class: Product product = new Product(); List productList = product.getProductList(dbCon); Or something like that. This should keep proper MVC design. If anyone has a good reason why one should use JNDI rather than the servlet context, I'd like to here it. (I guess I can think of a few cases...). Also, I found the DAO (Data Access Object) pattern implemented in the JPetStore example helpful in learning how to properly seperate models and actions. JPetStore is a Struts implementation of Sun's J2EE PetStore. It uses its own database connection pooling, but the DAO stuff is good nonetheless. JPetStore can be found at http://ibatis.com/jpetstore/jpetstore.html Hope that helps. jaaron __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: dataSources outside of actionservlet
Thanks the last answer does the job, thanks jaaron.. The JNDI solution seemed a bit crack induced and a bit too cyptic for my low iq.. :) Cheers again mark On 17-12-2002 19:52, J Aaron Farr [EMAIL PROTECTED] wrote: On Tue, 17 Dec 2002 17:45, Mark [EMAIL PROTECTED] wrote: Thanks edgar.. For those folks who are starting out or don't read binary Context and InitialContext are part of the javax.naming package So you'll need to import javax.naming.Context; import javax.naming.InitialContext; The javadocs are less cryptic.. Sometimes is just knowing which ones one has to read.. Many thanks again mark On 17-12-2002 17:18, Edgar P. Dollin [EMAIL PROTECTED] wrote: Context env = (Context) new InitialContext().lookup(java:comp/env); DataSource ds = (DataSource) env.lookup(yourconnection); conn = ds.getConnection(); Here's another way to do it without using JNDI: Given a stuts-config.xml file with a datasource like this: data-sources data-source key=myDatabase type=org.apache.struts.util.GenericDataSource set-property property=url value= ... / ... /data-source /data-sources You can access a database connection in your Action like this: Connection dbCon = null; ServletContext context = servlet.getServletContext(); DataSource ds = (DataSource) context.getAttribute(myDatabase); try{ dbCon = ds.getConnection(); ... Now at this point you want to use a model or business object that handles that actual logic. For example, suppose we have a Product class: Product product = new Product(); List productList = product.getProductList(dbCon); Or something like that. This should keep proper MVC design. If anyone has a good reason why one should use JNDI rather than the servlet context, I'd like to here it. (I guess I can think of a few cases...). Also, I found the DAO (Data Access Object) pattern implemented in the JPetStore example helpful in learning how to properly seperate models and actions. JPetStore is a Struts implementation of Sun's J2EE PetStore. It uses its own database connection pooling, but the DAO stuff is good nonetheless. JPetStore can be found at http://ibatis.com/jpetstore/jpetstore.html Hope that helps. jaaron __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- 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]
Datasources and Connection
Hi, I am using Tomcat for Struts and MS SQL Driver SQL Server 2000. Can any one tell me how to configure the Datasources and then to get a connection from that datasource. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Datasources and Connection
See the user guide for config info http://jakarta.apache.org/struts/userGuide/building_controller.html#other_config Also, look at the struts-config.dtd for available elements and attributes. David From: Dinesh [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Datasources and Connection Date: Thu, 05 Dec 2002 19:38:32 +0530 Hi, I am using Tomcat for Struts and MS SQL Driver SQL Server 2000. Can any one tell me how to configure the Datasources and then to get a connection from that datasource. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ Help STOP SPAM with the new MSN 8 and get 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: datasources
Ok, checkout, modify, and check back in the struts-config.xml. Then, you'd get what you want from your source control system. ... or is there some reason you can't do that? If you have to put notes in for changes just state that you modified the datasource for production or that you modified the datasource for development ... or something like that. I don't see why that wouldn't work, but you may well throw another wrench into my plan. If you're unable to modify the config file, repost with a different subject. Something like ... How do I initialize a datasource? Surely you'll get more attention then. HTH! Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, April 29, 2002 11:39 AM Subject: RE: datasources The problem with this is that the next time we run a build the latest struts-config.xml is retrieved from source control. I know I can create the datasource manually on initialization, but I'm trying to let Struts handle it somehow as you suggest. - Arash -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 12:24 To: Struts Users Mailing List Subject: Re: datasources You could always comment one of them out, depending on which environment you're running in, and save yourself having to do anything else =) ... I'm lazy though. Just surround the definition you don't want initialized with: !-- You just made your datasource definition a comment. Restart Tomcat =) -- You'll have to look to another person to provide you a way to initialize the datasource yourself if you don't like my suggestion. I tend to let Struts do whatever it can for me. HTH, Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 29, 2002 9:55 AM Subject: datasources We have a couple datasources defined in our application (in struts-config.xml) under separate keys (one is for our dev environment, and the other for production). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet? I already have a constant defined in a resource file so my application can determine which datasource to use. Any suggestions? (Struts 1.1 beta 1, Tomcat 4.03, Sun JDK 1.3.1) Thanks, Arash -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:struts-user- [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: datasources
On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:08:24 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Ok, checkout, modify, and check back in the struts-config.xml. Then, you'd get what you want from your source control system. ... or is there some reason you can't do that? If you have to put notes in for changes just state that you modified the datasource for production or that you modified the datasource for development ... or something like that. I don't see why that wouldn't work, but you may well throw another wrench into my plan. Another way to deal with the different data sources in development and production issue is to use the JNDI resources facilities of your app server instead. That way, your application would always use a symbolic reference to a particular data source (defined with a resource-ref or resource-env-ref element in web.xml), which would be connected to the correct database at deployment time via appropriate app server configuration settings. All J2EE app servers support this facility, plus several other basic servlet containers (including Tomcat 4 -- see the jndi-resources-howto.html file in the Tomcat 4 documentation). If you're unable to modify the config file, repost with a different subject. Something like ... How do I initialize a datasource? Surely you'll get more attention then. HTH! Eddie Craig - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, April 29, 2002 11:39 AM Subject: RE: datasources The problem with this is that the next time we run a build the latest struts-config.xml is retrieved from source control. I know I can create the datasource manually on initialization, but I'm trying to let Struts handle it somehow as you suggest. - Arash -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 12:24 To: Struts Users Mailing List Subject: Re: datasources You could always comment one of them out, depending on which environment you're running in, and save yourself having to do anything else =) ... I'm lazy though. Just surround the definition you don't want initialized with: !-- You just made your datasource definition a comment. Restart Tomcat =) -- You'll have to look to another person to provide you a way to initialize the datasource yourself if you don't like my suggestion. I tend to let Struts do whatever it can for me. HTH, Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 29, 2002 9:55 AM Subject: datasources We have a couple datasources defined in our application (in struts-config.xml) under separate keys (one is for our dev environment, and the other for production). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet? I already have a constant defined in a resource file so my application can determine which datasource to use. Any suggestions? (Struts 1.1 beta 1, Tomcat 4.03, Sun JDK 1.3.1) Thanks, Arash -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:struts-user- [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: datasources
Thanks Craig!! I had previously shied away from using the Tomcat datasource because I heard it wasn't up to snuff. However, I am told that the commons data source is supposedly up to snuff and will be included with Tomcat soon. ... I don't recall what the issues were with the Tomcat datasource at the time - it's been a while. I tend to just keep a general memory of things like that. I decide at the time it's not what I want to use based off what I find and just remember that it's not a good thing to use. ... however if the commons datasource is good, as is reported - and assuming Tomcat does adopt that datasource - then that would be the most ideal solution yet. Thanks so much! Eddie - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 12:17 PM Subject: Re: datasources On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:08:24 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Ok, checkout, modify, and check back in the struts-config.xml. Then, you'd get what you want from your source control system. ... or is there some reason you can't do that? If you have to put notes in for changes just state that you modified the datasource for production or that you modified the datasource for development ... or something like that. I don't see why that wouldn't work, but you may well throw another wrench into my plan. Another way to deal with the different data sources in development and production issue is to use the JNDI resources facilities of your app server instead. That way, your application would always use a symbolic reference to a particular data source (defined with a resource-ref or resource-env-ref element in web.xml), which would be connected to the correct database at deployment time via appropriate app server configuration settings. All J2EE app servers support this facility, plus several other basic servlet containers (including Tomcat 4 -- see the jndi-resources-howto.html file in the Tomcat 4 documentation). If you're unable to modify the config file, repost with a different subject. Something like ... How do I initialize a datasource? Surely you'll get more attention then. HTH! Eddie Craig - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, April 29, 2002 11:39 AM Subject: RE: datasources The problem with this is that the next time we run a build the latest struts-config.xml is retrieved from source control. I know I can create the datasource manually on initialization, but I'm trying to let Struts handle it somehow as you suggest. - Arash -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 12:24 To: Struts Users Mailing List Subject: Re: datasources You could always comment one of them out, depending on which environment you're running in, and save yourself having to do anything else =) ... I'm lazy though. Just surround the definition you don't want initialized with: !-- You just made your datasource definition a comment. Restart Tomcat =) -- You'll have to look to another person to provide you a way to initialize the datasource yourself if you don't like my suggestion. I tend to let Struts do whatever it can for me. HTH, Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 29, 2002 9:55 AM Subject: datasources We have a couple datasources defined in our application (in struts-config.xml) under separate keys (one is for our dev environment, and the other for production). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet? I already have a constant defined in a resource file so my application can determine which datasource to use. Any suggestions? (Struts 1.1 beta 1, Tomcat 4.03, Sun JDK 1.3.1) Thanks, Arash -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:struts-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto
Re: datasources
On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:39:41 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Thanks Craig!! I had previously shied away from using the Tomcat datasource because I heard it wasn't up to snuff. However, I am told that the commons data source is supposedly up to snuff and will be included with Tomcat soon. It's already there in the nightly builds, and in the test 4.1.0 release. ... I don't recall what the issues were with the Tomcat datasource at the time - it's been a while. I tend to just keep a general memory of things like that. I decide at the time it's not what I want to use based off what I find and just remember that it's not a good thing to use. Most of the issues were with the Tyrex implementation that was used in 4.0.x - thankfully, those problems go away now. ... however if the commons datasource is good, as is reported - and assuming Tomcat does adopt that datasource - then that would be the most ideal solution yet. Thanks so much! Eddie Craig - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 12:17 PM Subject: Re: datasources On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:08:24 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Ok, checkout, modify, and check back in the struts-config.xml. Then, you'd get what you want from your source control system. ... or is there some reason you can't do that? If you have to put notes in for changes just state that you modified the datasource for production or that you modified the datasource for development ... or something like that. I don't see why that wouldn't work, but you may well throw another wrench into my plan. Another way to deal with the different data sources in development and production issue is to use the JNDI resources facilities of your app server instead. That way, your application would always use a symbolic reference to a particular data source (defined with a resource-ref or resource-env-ref element in web.xml), which would be connected to the correct database at deployment time via appropriate app server configuration settings. All J2EE app servers support this facility, plus several other basic servlet containers (including Tomcat 4 -- see the jndi-resources-howto.html file in the Tomcat 4 documentation). If you're unable to modify the config file, repost with a different subject. Something like ... How do I initialize a datasource? Surely you'll get more attention then. HTH! Eddie Craig - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, April 29, 2002 11:39 AM Subject: RE: datasources The problem with this is that the next time we run a build the latest struts-config.xml is retrieved from source control. I know I can create the datasource manually on initialization, but I'm trying to let Struts handle it somehow as you suggest. - Arash -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 12:24 To: Struts Users Mailing List Subject: Re: datasources You could always comment one of them out, depending on which environment you're running in, and save yourself having to do anything else =) ... I'm lazy though. Just surround the definition you don't want initialized with: !-- You just made your datasource definition a comment. Restart Tomcat =) -- You'll have to look to another person to provide you a way to initialize the datasource yourself if you don't like my suggestion. I tend to let Struts do whatever it can for me. HTH, Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 29, 2002 9:55 AM Subject: datasources We have a couple datasources defined in our application (in struts-config.xml) under separate keys (one is for our dev environment, and the other for production). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet
Re: datasources
Yes - correct - the Tyrex implementation was the problem. I remember that now - and it's comforting to hear that those issues have been resolved by introducing the commons datasource. Thanks again Craig =) Eddie - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 1:22 PM Subject: Re: datasources On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:39:41 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Thanks Craig!! I had previously shied away from using the Tomcat datasource because I heard it wasn't up to snuff. However, I am told that the commons data source is supposedly up to snuff and will be included with Tomcat soon. It's already there in the nightly builds, and in the test 4.1.0 release. ... I don't recall what the issues were with the Tomcat datasource at the time - it's been a while. I tend to just keep a general memory of things like that. I decide at the time it's not what I want to use based off what I find and just remember that it's not a good thing to use. Most of the issues were with the Tyrex implementation that was used in 4.0.x - thankfully, those problems go away now. ... however if the commons datasource is good, as is reported - and assuming Tomcat does adopt that datasource - then that would be the most ideal solution yet. Thanks so much! Eddie Craig - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Tuesday, April 30, 2002 12:17 PM Subject: Re: datasources On Tue, 30 Apr 2002, Eddie Bush wrote: Date: Tue, 30 Apr 2002 12:08:24 -0500 From: Eddie Bush [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: datasources Ok, checkout, modify, and check back in the struts-config.xml. Then, you'd get what you want from your source control system. ... or is there some reason you can't do that? If you have to put notes in for changes just state that you modified the datasource for production or that you modified the datasource for development ... or something like that. I don't see why that wouldn't work, but you may well throw another wrench into my plan. Another way to deal with the different data sources in development and production issue is to use the JNDI resources facilities of your app server instead. That way, your application would always use a symbolic reference to a particular data source (defined with a resource-ref or resource-env-ref element in web.xml), which would be connected to the correct database at deployment time via appropriate app server configuration settings. All J2EE app servers support this facility, plus several other basic servlet containers (including Tomcat 4 -- see the jndi-resources-howto.html file in the Tomcat 4 documentation). If you're unable to modify the config file, repost with a different subject. Something like ... How do I initialize a datasource? Surely you'll get more attention then. HTH! Eddie Craig - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, April 29, 2002 11:39 AM Subject: RE: datasources The problem with this is that the next time we run a build the latest struts-config.xml is retrieved from source control. I know I can create the datasource manually on initialization, but I'm trying to let Struts handle it somehow as you suggest. - Arash -Original Message- From: Eddie Bush [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 12:24 To: Struts Users Mailing List Subject: Re: datasources You could always comment one of them out, depending on which environment you're running in, and save yourself having to do anything else =) ... I'm lazy though. Just surround the definition you don't want initialized with: !-- You just made your datasource definition a comment. Restart Tomcat =) -- You'll have to look to another person to provide you a way to initialize the datasource yourself if you don't like my suggestion. I tend to let Struts do whatever it can for me. HTH, Eddie - Original Message - From: Ramin, Arash [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 29, 2002 9:55 AM Subject: datasources We have a couple
datasources
We have a couple datasources defined in our application (in struts-config.xml) under separate keys (one is for our dev environment, and the other for production). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet? I already have a constant defined in a resource file so my application can determine which datasource to use. Any suggestions? (Struts 1.1 beta 1, Tomcat 4.03, Sun JDK 1.3.1) Thanks, Arash -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
multiple datasources
Subject: multiple datasources From: Arash Ramin [EMAIL PROTECTED] === We have a couple datasources defined in our application (in struts-config.xml). The default behaviour for Struts is to initialize all the defined datasources and make them available to the application. Depending on which environment we're running in, only one of them should be initialized. How can I do this conditionally? Can I tell Struts not to initialize the datasources automatically so I can do it manually in my own servlet? (Struts 1.1 beta 1, Tomcat 4.03, Sun JDK 1.3.1) Thanks, Arash -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Multiple Datasources
I have a strange problem, can someone tell me what is wrong? I use form based authentication with Websphere using custom registry, setup in web.xml is as below. when I tried to access a protected resource URL, http://bhn.gers.com:9080/furnnet/main/dispatcher.do, since everything under dir /main is defined to be protected in the web.xml, I was brought to the login page as expected, after submit the form with the j_username and j_password, I got a 404 file not found, as below, but in fact the user had been authenticated because if I resubmit the same URL link, I was able to access that URL link. Can someon tell me what is wrong with it or my setup? thanks Binh security-constraint id=SecurityConstraint_1 web-resource-collection id=WebResourceCollection_1 web-resource-namefn access/web-resource-name url-pattern/main/*/url-pattern http-methodPOST/http-method http-methodGET/http-method /web-resource-collection auth-constraint id=AuthConstraint_1 descriptionfn access:+:/description role-namefnUser/role-name /auth-constraint user-data-constraint id=UserDataConstraint_1 transport-guaranteeNONE/transport-guarantee /user-data-constraint /security-constraint login-config id=LoginConfig_1 auth-methodFORM/auth-method realm-namedbRealm/realm-name form-login-config id=FormLoginConfig_1 form-login-page/logon.html/form-login-page form-error-page/error.jsp/form-error-page /form-login-config /login-config security-role id=SecurityRole_1 role-namefnUser/role-name /security-role __ Do You Yahoo!? Try FREE Yahoo! Mail - the world's greatest free email! http://mail.yahoo.com/ -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
datasources management
What is the benefit of configuring datasources in the struts-config.xml file? My meaning is, I am revising an existing webapp to use struts. Obviously, I replaced my home-grown controller because struts has so many more features. But, I'm not sure I gain by replacing my home-grown datasource manager. I am using WebSphere, so presumably I don't need pool man. Data sources are defined in a property file (not xml, but good enough) and are cached. Am I over-looking something? Will I miss out on some features if I keep datasource management separate from struts classes? Isn't limiting access to datasources to the ActionServlet rather limiting? Mike -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
datasources
i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: datasources
When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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]
RES: datasources
ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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: datasources
Rubens, You can use key=dataSourceName attribute in data-source tag. To retrieve: ActionServlet.findDataSource( dataSourceName) Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:46 PM To: Struts Users Mailing List Subject: RES: datasources ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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] -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: datasources
You're right. I'm wrong. From J2EE datasources I just assumed there would be one, given that it's obvious someone would want to configure more than one data source, and the method taking a string. Anyone else? Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:46 PM To: Struts Users Mailing List Subject: RES: datasources ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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]
RES: datasources
Thank you Mark, but It´s not working. I´ve done this: data-sources data-source set-property property=key value=ds1/ set-property property=description value=ds1 Data Source/ ... ... /data-source data-source set-property property=key value=ds2/ set-property property=description value=ds2 Data Source/ ... ... /data-source /data-sources and in my class: action.findDataSource(ds1) But he loads just the ds2! Thank you, Rubens -Mensagem original- De: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 18:04 Para: 'Struts Users Mailing List' Assunto: RE: datasources Rubens, You can use key=dataSourceName attribute in data-source tag. To retrieve: ActionServlet.findDataSource( dataSourceName) Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:46 PM To: Struts Users Mailing List Subject: RES: datasources ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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] -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- 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: datasources
I am using struts 1.0 and it works for me, however I don't use set-property attribute and assign each property directly. E.g.: data-sources data-source autoCommit=true description=some db1 key=ds1 / data-source autoCommit=true description=some db2 key=ds2 / /data-sources Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 3:18 PM To: Struts Users Mailing List Subject: RES: datasources Thank you Mark, but It´s not working. I´ve done this: data-sources data-source set-property property=key value=ds1/ set-property property=description value=ds1 Data Source/ ... ... /data-source data-source set-property property=key value=ds2/ set-property property=description value=ds2 Data Source/ ... ... /data-source /data-sources and in my class: action.findDataSource(ds1) But he loads just the ds2! Thank you, Rubens -Mensagem original- De: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 18:04 Para: 'Struts Users Mailing List' Assunto: RE: datasources Rubens, You can use key=dataSourceName attribute in data-source tag. To retrieve: ActionServlet.findDataSource( dataSourceName) Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:46 PM To: Struts Users Mailing List Subject: RES: datasources ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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] -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- 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] -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only
RES: datasources
Thank You Mark: It worked. However, could you explain why the other way didn´t worked? Hey guys let´s update that manual! Rubens -Mensagem original- De: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 18:27 Para: 'Struts Users Mailing List' Assunto: RE: datasources I am using struts 1.0 and it works for me, however I don't use set-property attribute and assign each property directly. E.g.: data-sources data-source autoCommit=true description=some db1 key=ds1 / data-source autoCommit=true description=some db2 key=ds2 / /data-sources Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 3:18 PM To: Struts Users Mailing List Subject: RES: datasources Thank you Mark, but It´s not working. I´ve done this: data-sources data-source set-property property=key value=ds1/ set-property property=description value=ds1 Data Source/ ... ... /data-source data-source set-property property=key value=ds2/ set-property property=description value=ds2 Data Source/ ... ... /data-source /data-sources and in my class: action.findDataSource(ds1) But he loads just the ds2! Thank you, Rubens -Mensagem original- De: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 18:04 Para: 'Struts Users Mailing List' Assunto: RE: datasources Rubens, You can use key=dataSourceName attribute in data-source tag. To retrieve: ActionServlet.findDataSource( dataSourceName) Mark. -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:46 PM To: Struts Users Mailing List Subject: RES: datasources ok, but in the struts-config.xml there isn´t a name tag. How can I specify the name of the dataSource ?. For example, this below: data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Odonto Data Source/ set-property property=driverClass value=sun.jdbc.odbc.JdbcOdbcDriver/ set-property property=maxCount value=10/ set-property property=minCount value=2/ set-property property=password value=foo/ set-property property=url value=jdbc:odbc:odonto/ set-property property=user value=bar/ /data-source /data-sources where is the tag name ?? Thank you -Mensagem original- De: Taylor Cowan [mailto:[EMAIL PROTECTED]] Enviada em: sexta-feira, 11 de janeiro de 2002 16:48 Para: Struts Users Mailing List Assunto: RE: datasources When you configured the datasource you gave it a name. Use that as a key to lookup the datasoruce using findDataSource( String name ) Taylor -Original Message- From: Rubens Gama [mailto:[EMAIL PROTECTED]] Sent: Friday, January 11, 2002 2:38 PM To: Struts-User Subject: datasources i have two datasources defined in the struts-config.xml. how can i reference each one from my application? for example: servlet.findDataSource(1) or servlet.findDataSource(2) thanks in advance -- 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] -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -- 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] -- This message
DataSources Problem: 2 DataSources won't work!
Hi, we are currently working with Struts and a single database (mysql). Now, we wanted to use a second database pooling for a oracle database. We updated our struts-config to contain a second data-source tag. data-sources data-source set-property property=key value=mysql/ set-property property=autoCommit value=true/ set-property property=description value=MySQL Data Source Configuration/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=password value=mysql/ set-property property=url value=jdbc:mysql://localhost:3306/dbjava/ set-property property=user value=root/ /data-source data-source autoCommit=true description=Oracle Data Source Configuration driverClass=oracle.jdbc.driver.OracleDriver maxCount=4 minCount=2 password=xxx url=jdbc:oracle:thin:@141.28.xxx.xxx:1521:FHF user=Schippmann key=oracle / /data-sources-- /data-sources We tested the connection to the oracle db with a thin Driver, it worked perfectly. Cannot find ActionMappings or FormBeans Declarations is the error we get, I know that it has absolutely nothing to do with datasources, but this is the error we get if we add the second datasource! We also tried to use the set-property tag inside the data-sources, but the same error occured. We really appreciate any kind of help we can get, thanx, Sven Haiges -- Sven Haiges mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: DataSources Problem: 2 DataSources won't work!
I usually get that problem when there is a problem with the actual xml in struts-config (eg, I left out a closing tag, etc). Is this exactly like your struts-config xml looks? If so, you have a problem at the end - there are 2 closing /data-sources tags - one is actually data-sources-- If that doesn't work, check the rest of the file for mistakes. Hope that helps, Rob -Original Message- From: Sven Haiges [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 12, 2001 5:01 PM To: [EMAIL PROTECTED] Subject: DataSources Problem: 2 DataSources won't work! Hi, we are currently working with Struts and a single database (mysql). Now, we wanted to use a second database pooling for a oracle database. We updated our struts-config to contain a second data-source tag. data-sources data-source set-property property=key value=mysql/ set-property property=autoCommit value=true/ set-property property=description value=MySQL Data Source Configuration/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=password value=mysql/ set-property property=url value=jdbc:mysql://localhost:3306/dbjava/ set-property property=user value=root/ /data-source data-source autoCommit=true description=Oracle Data Source Configuration driverClass=oracle.jdbc.driver.OracleDriver maxCount=4 minCount=2 password=xxx url=jdbc:oracle:thin:@141.28.xxx.xxx:1521:FHF user=Schippmann key=oracle / /data-sources-- /data-sources We tested the connection to the oracle db with a thin Driver, it worked perfectly. Cannot find ActionMappings or FormBeans Declarations is the error we get, I know that it has absolutely nothing to do with datasources, but this is the error we get if we add the second datasource! We also tried to use the set-property tag inside the data-sources, but the same error occured. We really appreciate any kind of help we can get, thanx, Sven Haiges -- Sven Haiges 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]
Multiple datasources - is this working at all ?
Hi all, I went through the whole mail-list , even the archive, found some solutions but none of them worked for me. Maybe I have some problems with my setup, so here is my info, please help : In the struts-config.xml : - data-sources data-source set-property property=key value=1 / set-property property=description value=1 / set-property property=driverClass value =org.gjt.mm.mysql.Driver/ set-property property=maxCount value=10 / set-property property=minCount value=2/ set-property property=url value=jdbc:mysql://localhost/db1 / set-property property=user value=user1 / set-property property=password value=passwd1/ /data-source data-source set-property property=key value=2 / set-property property=description value=2 / set-property property=driverClass value =org.gjt.mm.mysql.Driver/ set-property property=maxCount value=5 / set-property property=minCount value=1/ set-property property=url value=jdbc:mysql://localhost/db2 / set-property property=user value=user2 / set-property property=password value=passwd2/ /data-source /data-sources --- in my code ( Action ) I was trying to use : 1. DataSource dataSource = servlet.findDataSource(1); 2. Connection connection = dataSource.getConnection(); however an NullPointerException is thrown on the second line of the code (2. ), that I think means that the dataSource was null, so it cannot find the dataSource with the key 1. The same happens for key 2. but when I do : 1. DataSource dataSource = servlet.findDataSource(null); the code works fine, and I get a handle to the connection. I need to be able to use both connections. Am I missing something ? Thank you. Jano Fetyko Script fighter
RE: How to use multiple datasources ?
Add the attribute 'key=abc' to your data-source configuration. In your action class, use DataSource ds = servlet.findDataSource("abc"); Mark -Original Message- From: Zeltser, Mark [mailto:[EMAIL PROTECTED]] Sent: 09 April 2001 15:52 To: '[EMAIL PROTECTED]' Subject: RE: How to use multiple datasources ? I am interested in this one too... Mark. -Original Message- From: Szlapa, Michael [SMTP:[EMAIL PROTECTED]] Sent: Friday, April 06, 2001 2:05 PM To: '[EMAIL PROTECTED]' Subject: How to use multiple datasources ? Does anyone know how to configure and use multiple datasources ? Thanks in advance Michael -Original Message- From: Szlapa, Michael [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 04, 2001 11:11 AM To: '[EMAIL PROTECTED]' Subject:How to use multiple datasources ? Hi I have problems understanding how I should configure multiple datasources to be used in single application, possibly even in single Action or JSP page. I've read in API description of ActionServlet.dataSources The JDBC data sources that has been configured for this application, if any, keyed by the servlet context attribute under which they are stored. I guess I don't understand what "servlet context attribute" means here, I have only one application with one servlet (ActionServlet), how I should configure name of the context attribute ? I think it would be nice if I could specify datasource name in the struts-config like: data-sources data-source autoCommit="false" name="My name" description="Trial access to database" driverClass="oracle.jdbc.driver.OracleDriver" maxCount="4" minCount="2" password="123" url="jdbc:oracle:thin:@ado:1521:123" user="123" / /data-sources and then do findDataSource("My name"); I have looked also at the Struts guide to find more about data-source section, but it only talks about default connection. TIA Michael -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers Inc. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. *** This email message contains confidential information for the above addressee only. If you are not the intended addressee you must not disclose or use the information in any manner whatsoever. Any opinion or views contained in this email message are those of the sender, do not represent those of the Company in any way and reliance should not be placed upon its contents. Unless otherwise stated this email message is not intended to be contractually binding. Where an Agreement exists between our respective companies and there is conflict between the contents of this email message and the Agreement then the terms of that Agreement shall prevail. Abbey National Treasury Services plc. Registered in England. Registered Office: Abbey House, Baker Street, London NW1 6XL. Company Registration No: 2338548. Regulated by the SFA ***
datasources action servlet
Hi, I was wondering if I could configure the action servlet to pick up the datasources from a different file (not struts-config). I am trying to auto-generate the struts app for different users - the thing is the action mappings are the same for all of them so I would prefer to use a constant struts-config file for the action mappings. but the data sources are dependent on user input and know way of knowing what they could be ahead of time - I would like to place this info in a different file. Would anyone happen to know what the best way to do this is? thanks Pratima
RE: datasources action servlet
It looks like one option is to modify the dtd and declare a different entity that holds all the datasources - is there a less intrusive way/ is this recommended/strongly discouraged? thanks pratima -Original Message- From: Gogineni, Pratima Sent: Friday, March 09, 2001 12:29 PM To: '[EMAIL PROTECTED]' Subject: datasources action servlet Hi, I was wondering if I could configure the action servlet to pick up the datasources from a different file (not struts-config). I am trying to auto-generate the struts app for different users - the thing is the action mappings are the same for all of them so I would prefer to use a constant struts-config file for the action mappings. but the data sources are dependent on user input and know way of knowing what they could be ahead of time - I would like to place this info in a different file. Would anyone happen to know what the best way to do this is? thanks Pratima