RHEL, mysql 4.1.9 tomcat 5028, form authentication login failure.
After chasing for a day, a nasty arose I thought others might like to know of. rhel has /etc/hosts localhost entry as 127.0.0.1 localhost.localdomain localhost If you use form authentication, with server.xml entries such as Realm className=org.apache.catalina.realm.JDBCRealm debug=0 driverName=com.mysql.jdbc.Driver connectionURL=jdbc:mysql://localhost/tcusers connectionName=tomcat connectionPassword=s userTable=x userNameCol=y userCredCol=z / then the connection is most likely to fail, not allowed, mysql error indicating that this user is invalid as [EMAIL PROTECTED] reverse the /etc/hosts entry such that localhost is found first and it works. 127.0.0.1localhost localhost.localdomain Sheesh. regards DaveP. ** snip here ** Regards DaveP. snip here * -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: RHEL, mysql 4.1.9 tomcat 5028, form authentication login failure.
Or grant privileges on the database to 'x'@'localhost' and 'x'@'localhost.localdomain'. Then give both accounts the same password. It won't matter which one mysql sees because they'll both work. For the record, mysql does a reverse lookup of the host and makes that part of the credentials matching it up with the host field in the mysql.user table. I suppose you could use 'x'@'localhost%', but what's to stop some fool from naming his system 'localhost-spoof.mydomain.com' and attempting a hack. --David Pawson, David wrote: After chasing for a day, a nasty arose I thought others might like to know of. rhel has /etc/hosts localhost entry as 127.0.0.1 localhost.localdomain localhost If you use form authentication, with server.xml entries such as Realm className=org.apache.catalina.realm.JDBCRealm debug=0 driverName=com.mysql.jdbc.Driver connectionURL=jdbc:mysql://localhost/tcusers connectionName=tomcat connectionPassword=s userTable=x userNameCol=y userCredCol=z / then the connection is most likely to fail, not allowed, mysql error indicating that this user is invalid as [EMAIL PROTECTED] reverse the /etc/hosts entry such that localhost is found first and it works. 127.0.0.1localhost localhost.localdomain Sheesh. regards DaveP. ** snip here ** Regards DaveP. snip here * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: RHEL, mysql 4.1.9 tomcat 5028, form authentication login failure.
-Original Message- From: David Smith Or grant privileges on the database to 'x'@'localhost' and 'x'@'localhost.localdomain'. Then give both accounts the same password. It won't matter which one mysql sees because they'll both work. Thanks, easier than tweaking each new install of rhel. For the record, mysql does a reverse lookup of the host and makes that part of the credentials matching it up with the host field in the mysql.user table. I added a note to the mysql man pages, hopefully might trigger others to avoid this one. regards DaveP. ** snip here ** -- DISCLAIMER: NOTICE: The information contained in this email and any attachments is confidential and may be privileged. If you are not the intended recipient you should not use, disclose, distribute or copy any of the content of it or of any attachment; you are requested to notify the sender immediately of your receipt of the email and then to delete it and any attachments from your system. RNIB endeavours to ensure that emails and any attachments generated by its staff are free from viruses or other contaminants. However, it cannot accept any responsibility for any such which are transmitted. We therefore recommend you scan all attachments. Please note that the statements and views expressed in this email and any attachments are those of the author and do not necessarily represent those of RNIB. RNIB Registered Charity Number: 226227 Website: http://www.rnib.org.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL / MYSQL JDBC / TOMCAT 5
On Mon, Aug 23, 2004 at 09:09:45AM -0400, Williams, Mark L CIV NSWC-PC wrote: : That said, are there any observations about the feasibility of using : Swing for building GUIs to be used via browser? Using the web as a conduit for applets (Swing apps) defeats the purpose of the web's thin-client design. ;) If you want a web-based app, aim for thin technologies -- that is, server-side computations and resources -- and you can save yourself some headaches. : I find too many : unexpected browser peculiarities when trying to do anything too : complicated (probably just me, but...) and would like to use something : more definitively controlled (or more predictable in operation). All my : users will be using MS Internet Explorer, typically v5.5. If you have control over the deployment environment then you can go whole-hog with browser-specific markup and javascript. Many companies do this internally and it simplifies testing, deployment, etc. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JSTL / MYSQL JDBC / TOMCAT 5
Again, I appreciate the feedback. We are working in a rather controlled environment these days and it turns out that the Java plug-in won't go, so the whole applet idea looks to be a non-starter anyway. Live and learn. (or not, I guess...) VR/ Mark -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 24, 2004 1:08 To: Tomcat Users List Subject: Re: JSTL / MYSQL JDBC / TOMCAT 5 On Mon, Aug 23, 2004 at 09:09:45AM -0400, Williams, Mark L CIV NSWC-PC wrote: : That said, are there any observations about the feasibility of using : Swing for building GUIs to be used via browser? Using the web as a conduit for applets (Swing apps) defeats the purpose of the web's thin-client design. ;) If you want a web-based app, aim for thin technologies -- that is, server-side computations and resources -- and you can save yourself some headaches. : I find too many : unexpected browser peculiarities when trying to do anything too : complicated (probably just me, but...) and would like to use something : more definitively controlled (or more predictable in operation). All my : users will be using MS Internet Explorer, typically v5.5. If you have control over the deployment environment then you can go whole-hog with browser-specific markup and javascript. Many companies do this internally and it simplifies testing, deployment, etc. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
RE: JSTL / MYSQL JDBC / TOMCAT 5
Thanks, that worked. I also appreciate the reference to the XML validator. That said, are there any observations about the feasibility of using Swing for building GUIs to be used via browser? I find too many unexpected browser peculiarities when trying to do anything too complicated (probably just me, but...) and would like to use something more definitively controlled (or more predictable in operation). All my users will be using MS Internet Explorer, typically v5.5. Googling gives several old articles on needing plug-ins and the like; any more current experiences available? If Swing is not practical, how are folks handling this kind of issue? TIA... Mark -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Friday, August 20, 2004 16:15 To: Tomcat Users List Subject: Re: JSTL / MYSQL JDBC / TOMCAT 5 On Fri, Aug 20, 2004 at 05:11:09PM -0400, Williams, Mark L CIV NSWC-PC wrote: : Here's the extract from the example. Would anyone like to tell me how to : fix it (if I leave it as-is, not only is there no XML tag at the top, : but I get a XML document structures must start and end within the same : entity. error)? I'll learn it some day, but if I had leisure, I : wouldn't be asking for help... : ===extract starts here== : web-app xmlns=http://java.sun.com/xml/ns/j2ee; : xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; : xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; : version=2.4 : web-app Long story short: XML tags are like parentheses or curly braces in code; they must balance. What you have here is the equivalent of { { } aka, no closing } Take out the second web-app tag. If you're too short on time to learn XML, invest in a validation tool. A free one comes with Expat, something like xmlwf. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
JSTL / MYSQL JDBC / TOMCAT 5
Folks: I've run through the instructions at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples -howto.html for MySQL and have thrashed through the process to the point that I'm convinced that I have a database connection (I can get lots of errors from MySQL itself and I've put a sql:update command in that inserted a row in the test database). I've hunted all over and adapted a little test program for Oracle and have searched the TOMCAT archives. Sure, I may have missed something, but if I use the test program to query the database, the variable values aren't returned. For example, using this exact code from the site above: %@ taglib uri=http://java.sun.com/jsp/jstl/sql; prefix=sql % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % sql:query var=rs dataSource=jdbc/TestDB select id, foo, bar from testdata /sql:query html head titleDB Test/title /head body h2Results/h2 c:forEach var=row items=${rs.rows} Foo ${row.foo}br/ Bar ${row.bar}br/ /c:forEach /body /html gives me: Results Foo ${row.foo} Bar ${row.bar} Verbatim. And that's with two rows in the database now. Again, if I change the function to a sql:update and poke values into the database, they go in ok. The TOMCAT administrator shows the appropriate data source for the database. The Oracle example attempts to get the column names from a query and use those to label a SELECT * kind of retrieval. Any suggestions on what to try next (other than give up and go to regular servlets) would be greatly appreciated. VR/ Mark L. Williams Computer Scientist Naval Surface Warfare Center Panama City smime.p7s Description: S/MIME cryptographic signature
Re: JSTL / MYSQL JDBC / TOMCAT 5
On Fri, Aug 20, 2004 at 03:29:42PM -0400, Williams, Mark L CIV NSWC-PC wrote: : Foo ${row.foo} : Bar ${row.bar} : : Verbatim. : [snip] : Any suggestions on what to try next (other than give up and go to : regular servlets) would be greatly appreciated. Well, I'd usually vote for a servlet/JSP page controller setup ;) but I may be able to help you: What's the doctype declaration in your web.xml? You must specify servlet spec 2.4 to have the JSTL functionality you desire. I don't have the exact syntax on me, but you can find examples all over the web. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JSTL / MYSQL JDBC / TOMCAT 5
I see that must be where the problem is. I had trouble with the sample web.xml entries... TOMCAT wouldn't start the DBTest app with the example as-is, so I commented out the part that caused the immediate heartburn and that has the 2.4 spec in it. Here's the extract from the example. Would anyone like to tell me how to fix it (if I leave it as-is, not only is there no XML tag at the top, but I get a XML document structures must start and end within the same entity. error)? I'll learn it some day, but if I had leisure, I wouldn't be asking for help... And if it's really wrong, should someone fix the documentation? Or is it just not a cut-and-paste candidate? TIA, Mark ===extract starts here== web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 web-app descriptionMySQL Test App/description resource-ref descriptionDB Connection/description res-ref-namejdbc/TestDB/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref /web-app ==extract ends here=== -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Friday, August 20, 2004 15:49 To: Tomcat Users List Subject: Re: JSTL / MYSQL JDBC / TOMCAT 5 On Fri, Aug 20, 2004 at 03:29:42PM -0400, Williams, Mark L CIV NSWC-PC wrote: : Foo ${row.foo} : Bar ${row.bar} : : Verbatim. : [snip] : Any suggestions on what to try next (other than give up and go to : regular servlets) would be greatly appreciated. Well, I'd usually vote for a servlet/JSP page controller setup ;) but I may be able to help you: What's the doctype declaration in your web.xml? You must specify servlet spec 2.4 to have the JSTL functionality you desire. I don't have the exact syntax on me, but you can find examples all over the web. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
Re: JSTL / MYSQL JDBC / TOMCAT 5
On Fri, Aug 20, 2004 at 05:11:09PM -0400, Williams, Mark L CIV NSWC-PC wrote: : Here's the extract from the example. Would anyone like to tell me how to : fix it (if I leave it as-is, not only is there no XML tag at the top, : but I get a XML document structures must start and end within the same : entity. error)? I'll learn it some day, but if I had leisure, I : wouldn't be asking for help... : ===extract starts here== : web-app xmlns=http://java.sun.com/xml/ns/j2ee; : xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; : xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; : version=2.4 : web-app Long story short: XML tags are like parentheses or curly braces in code; they must balance. What you have here is the equivalent of { { } aka, no closing } Take out the second web-app tag. If you're too short on time to learn XML, invest in a validation tool. A free one comes with Expat, something like xmlwf. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JSTL / MYSQL JDBC / TOMCAT 5
I just noticed that this is the syntax given on http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-how to.html, complete with the double web-app tags so I wouldn't be surprised if a number of people run into this problem. -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Friday, August 20, 2004 5:15 PM To: Tomcat Users List Subject: Re: JSTL / MYSQL JDBC / TOMCAT 5 On Fri, Aug 20, 2004 at 05:11:09PM -0400, Williams, Mark L CIV NSWC-PC wrote: : Here's the extract from the example. Would anyone like to tell me how to : fix it (if I leave it as-is, not only is there no XML tag at the top, : but I get a XML document structures must start and end within the same : entity. error)? I'll learn it some day, but if I had leisure, I : wouldn't be asking for help... : ===extract starts here== : web-app xmlns=http://java.sun.com/xml/ns/j2ee; : xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; : xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; : version=2.4 : web-app Long story short: XML tags are like parentheses or curly braces in code; they must balance. What you have here is the equivalent of { { } aka, no closing } Take out the second web-app tag. If you're too short on time to learn XML, invest in a validation tool. A free one comes with Expat, something like xmlwf. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDBC + MySQL Datasource + Tomcat = ClassCastException
Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoReconnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
Ok - implemented the getGeneratedKeys() method and everything works great. Thank you very much Mike! On another topic, is there any quick way to determine the total rows returned in a ResultSet without stepping through it. I want to build array's or objects and I need to know in advance what the array dimension will be. I could use lists, but I'd rather use array's. Here's what I came up with: ResultSet rs = ps.executeQuery(); rs.last(); int total = rs.getRow(); rs.beforeFirst(); When I get the resultset, I go to the last row, get its number, and then reset the resultset cursor back to before the first row. Is there already a method to give me this data? I looked but couldn't find any... Joe -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 1:05 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JDBC + MySQL Datasource + Tomcat = ClassCastException
I've also wished for this, but I think the 'last, grab, first' two-step is the only way to do this.. and of course, only with JDBC 3.0 Scrollable ResultSets (or maybe that was available back in JDBC2). The only other way I can think of is to construct a query exactly the same as the one you are running, except replace the SELECT clause with SELECT COUNT(*). Run this once, either before or after your 'real' query. Of course this isn't so great for cases where someone else inserts a dozen rows between your two queries. -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 4:10 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException Ok - implemented the getGeneratedKeys() method and everything works great. Thank you very much Mike! On another topic, is there any quick way to determine the total rows returned in a ResultSet without stepping through it. I want to build array's or objects and I need to know in advance what the array dimension will be. I could use lists, but I'd rather use array's. Here's what I came up with: ResultSet rs = ps.executeQuery(); rs.last(); int total = rs.getRow(); rs.beforeFirst(); When I get the resultset, I go to the last row, get its number, and then reset the resultset cursor back to before the first row. Is there already a method to give me this data? I looked but couldn't find any... Joe -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 1:05 PM To: 'Tomcat Users List' Subject: RE: JDBC + MySQL Datasource + Tomcat = ClassCastException I'd drop the non-compliant way of getting this value, and use what's provided by JDBC 3.0 (available with JDK 1.4.x and ConnectorJ 3.x) statement.getGeneratedKeys() No casting required. http://www.mysql.com/articles/autoincrement-with-connectorj.html -Original Message- From: Joe Krause [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 2:49 PM To: '[EMAIL PROTECTED]' Subject: JDBC + MySQL Datasource + Tomcat = ClassCastException Hi Folks, I am trying to recast the JDBC Statement object that is given to me from a Connection object that I get out of Tomcat's datasource connection pool. If I recast the generic java.sql.Statement to a com.mysql.jdbc.Statment, I can use the non JDBC compliant methods such as getLastInsertID. When I do this in a test class using standard JDBC, it works perfectly. But when I try to do this from a connection object that is retrived from tomcat's connection pool, I get a ClassCastException. Does the datasource mechanism alter the connection somehow so that it would no longer give me com.mysql.jdbc.Statment objects, but some other kind? Here's the code that works... Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(:mysql://jedi.x:3306/vegas?autoRec onnect=true, username, password); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); Here's the code that doesn't work: Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/vegas); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); stmt.executeUpdate(INSERT INTO role VALUES (null, 'test', '123')); com.mysql.jdbc.Statement m = (com.mysql.jdbc.Statement) stmt; long id = m.getLastInsertID(); I should note that other than this, everything works fine with the datasource. Its configured properly (I think) and I can fully access the database in all respects. I am using: Tomcat 4.1.24 Linux 2.4.20 Mysql 4.0.13 Java 1.4.1.03 Mysql Connector/J 3.0.8 Thanks For the help! Joe Krause - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: MYSQL and TOMCAT
First of all you shouldn't rethrow the exception. That hides the true nature of the problem. -Original Message- From: jsp [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 4:17 AM To: 'Tomcat Users List' Subject: MYSQL and TOMCAT PreparedStatement updateInfo; updateInfo = con.prepareStatement( insert into info(?);); updateInfo.setString(1,Referer); updateInfo.execute(); } catch (SQLException sqle) { error = Update failed, possible duplicate entry; throw new SQLException( error ); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MYSQL and TOMCAT
What I see your are losing the real message of the error: catch (SQLException sqle) { error = Update failed, possible duplicate entry; throw new SQLException( error ); } Better you should do: catch (SQLException sqle) { System.out.println(sqle.getMessage()); //get the message from the exception // do something here to return the error upside } jsp wrote: Here is another beginner question of sorts I imagine. I receive this error. java.sql.SQLException: Update failed, possible duplicate entry I've got this code in a .jsp page. % String ref=request.getHeader(Referer);% BR % count.addInfo( ref ); % count is calling the method addInfo in a java bean... public void addInfo( String Referer ) throws SQLException, Exception { if (con != null) { try{ PreparedStatement updateInfo; updateInfo = con.prepareStatement( insert into info(?);); updateInfo.setString(1,Referer); updateInfo.execute(); } catch (SQLException sqle) { error = Update failed, possible duplicate entry; throw new SQLException( error ); } } else { error = Connection with database was lost.; throw new Exception( error ); } } Can anyone see the mistake I am making here. My database has one table now called info with one String field which is the primary key also. Thanks if anyone can help or point me to a webpage or something. -wiley - 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]
MYSQL and TOMCAT
Here is another beginner question of sorts I imagine. I receive this error. java.sql.SQLException: Update failed, possible duplicate entry I've got this code in a .jsp page. % String ref=request.getHeader(Referer);% BR % count.addInfo( ref ); % count is calling the method addInfo in a java bean... public void addInfo( String Referer ) throws SQLException, Exception { if (con != null) { try{ PreparedStatement updateInfo; updateInfo = con.prepareStatement( insert into info(?);); updateInfo.setString(1,Referer); updateInfo.execute(); } catch (SQLException sqle) { error = Update failed, possible duplicate entry; throw new SQLException( error ); } } else { error = Connection with database was lost.; throw new Exception( error ); } } Can anyone see the mistake I am making here. My database has one table now called info with one String field which is the primary key also. Thanks if anyone can help or point me to a webpage or something. -wiley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MYSQL and TOMCAT
java.sql.SQLException: Update failed, possible duplicate entry Let's see you have a table info with one field and that field is a primary key right? If I remember correctly, primary keys in a table have to be unique, so maybe you are calling your method with the same data again and again ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problem with mysql and tomcat
Dear Manny, I'm not an expert in mysql, but I did manage to run my apache2, tomcat 4 and mysql without any problem. I think the problem you have might not be the mm.mysql driver problem. It seems to me that either your sql statement(when you open the connection to mysql) is not quite right because the mysql server has denied your access to the database. Make sure you put your sql statement correctly when you open a connection. Below is the sample code I use to connect to mysql: String connectionURL = jdbc:mysql://servername/database_name; Connection connection = null; Statement statement = null; ResultSet resultSet = null; try { Class.forName(org.gjt.mm.mysql.Driver).newInstance(); connection = DriverManager.getConnection(connectionURL, username, password); statement = connection.createStatement(); resultSet = statement.executeQuery(SELECT Name, Username FROM tblUsers + ORDER BY Name); while (resultSet.next()){ out.println(trtd + resultSet.getString(Name) + /tdtd + resultSet.getString(Username) + /td/tr); } if (resultSet != null){ resultSet.close(); } } catch (ClassNotFoundException e){ System.err.println(Couldn't find the mm + database driver: + e getMessage()); } catch (InstantiationException e) { System.err.println(e.getMessage()); } catch (IllegalAccessException e) { System.err.println(e.getMessage()); } catch (SQLException e) { System.err.println(SQL Problem : + e.getMessage()); System.err.println(SQL State : + e.getSQLState()); System.err.println(Vendor Error: + e.getErrorCode()); } Just substitute those servername, database_name, username and password with your own. Hope this help. bye. Cheer, Brandon ---Original Message--- From: Tomcat Users List Date: Tuesday, April 23, 2002 01:38:04 AM To: [EMAIL PROTECTED] Subject: problem with mysql and tomcat hi i've downloaded the mysql and loaded the driver(mm.nysql) driver for it If i try to use it in a regular program without involving the server(tomcat3 2.1) it works fine . i can get the resultset etc which is fine. But when i created another applicatoin which involved the use of Tomcat it gives me error saying Started: 21:13:29.210 PM Error: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'username@localhost' (Using password: YES) i've looked at hundreds of webpages but nothing so far has revealed a suitable reaason and solution for it. one webpage said to put the jar file in WEB-INF/lib dir but in my version of tomcat3.2.1 theres no subdirectory as that . if anyone knows the solution to it please let me know.my email address is [EMAIL PROTECTED] thanks manny
problem with mysql and tomcat
hi i've downloaded the mysql and loaded the driver(mm.nysql) driver for it.If i try to use it in a regular program without involving the server(tomcat3.2.1) it works fine . i can get the resultset etc which is fine. But when i created another applicatoin which involved the use of Tomcat it gives me error saying Started: 21:13:29.210 PM Error: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'username@localhost' (Using password: YES) i've looked at hundreds of webpages but nothing so far has revealed a suitable reaason and solution for it. one webpage said to put the jar file in WEB-INF/lib dir but in my version of tomcat3.2.1 theres no subdirectory as that . if anyone knows the solution to it please let me know.my email address is [EMAIL PROTECTED] thanks manny
Re: problem with mysql and tomcat
Amrinder Singh wrote: hi i've downloaded the mysql and loaded the driver(mm.nysql) driver for it.If i try to use it in a regular program without involving the server(tomcat3.2.1) it works fine . i can get the resultset etc which is fine. But when i created another applicatoin which involved the use of Tomcat it gives me error saying Started: 21:13:29.210 PM Error: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'username@localhost' (Using password: YES) i've looked at hundreds of webpages but nothing so far has revealed a suitable reaason and solution for it. one webpage said to put the jar file in WEB-INF/lib dir but in my version of tomcat3.2.1 theres no subdirectory as that . Well, you wrote the web application right? So technically no directories exist until you put them there :) Applications running in tomcat get can load their classes from three main locations, /jre/lib/ext (Standard installed extensions, don't use this as it's a nightmare to maintain, believe me!), /$TOMCAT_HOME/lib (for general drivers that everything should be able to see) and /$TOMCAT_HOME/webapps/YOUR_APP/lib. So, the short answer (and I'm not even sure your problem is anything to do with this, but it's a faq anyway) is to create the 'lib' subdirectory and put the driver jar in it. Cheers, Tom -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: problem with mysql and tomcat
Hi! This Access denied for user username@localhost means that your username at localhost has to be in your mysql.user table. In that table you specify what usres at what hostnames can connect to mysql. Best regards, Kovi At 10:15 23.4.2002 +0100, you wrote: Amrinder Singh wrote: hi i've downloaded the mysql and loaded the driver(mm.nysql) driver for it.If i try to use it in a regular program without involving the server(tomcat3.2.1) it works fine . i can get the resultset etc which is fine. But when i created another applicatoin which involved the use of Tomcat it gives me error saying Started: 21:13:29.210 PM Error: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'username@localhost' (Using password: YES) i've looked at hundreds of webpages but nothing so far has revealed a suitable reaason and solution for it. one webpage said to put the jar file in WEB-INF/lib dir but in my version of tomcat3.2.1 theres no subdirectory as that . Well, you wrote the web application right? So technically no directories exist until you put them there :) Applications running in tomcat get can load their classes from three main locations, /jre/lib/ext (Standard installed extensions, don't use this as it's a nightmare to maintain, believe me!), /$TOMCAT_HOME/lib (for general drivers that everything should be able to see) and /$TOMCAT_HOME/webapps/YOUR_APP/lib. So, the short answer (and I'm not even sure your problem is anything to do with this, but it's a faq anyway) is to create the 'lib' subdirectory and put the driver jar in it. Cheers, Tom -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
RE: Mysql and Tomcat
Gareth, What are the errors? We're running mysql under Tomcat and our corresponding code is: Class.forName(org.gjt.mm.mysql.Driver).newInstance(); this.connection = DriverManager.getConnection(jdbc:mysql:// + this.databaseHost +: + this.databasePort + / + this.databaseName + ?user= + this.databaseUsername + password= + this.databasePassword); This works fine, but I guess it's more likely a class loading problem you're having. I'd check that mysql.jar is under Tomcat/common/lib. We've also got jdbc2_0-stdext.jar there, although I'm not sure this is required any more. Andy -Original Message- From: Lawrence, Gareth [mailto:[EMAIL PROTECTED]] Sent: 15 April 2002 05:53 To: 'Tomcat Users List' Subject: Mysql and Tomcat Greetings All, Just when I though everything was sweet I'm having a nasty problem. I'm running: Debian Linux, Tomcat 4.0.3, Mysql, Ant, MM JDBC driver. Basically I've set everything up sweet and when I run a test file from the command line (java test.class) I get a connection to the database no problems. Unfortunately when I try and do the same thing through a servlet loaded onto Tomcat I get grief!!! See below I get two errors outputted in the browser window, the second one could be caused by the first :-) If anyway has any ideas about this, please let me know this is a desperate one :-((( Thanks heaps and heaps, Gareth Code: try { //Registering the MySQL JDBC Driver Class.forName(org.gjt.mm.mysql.Driver).newInstance(); } catch (Exception E) { out.println(pException: Created Driver/p); System.err.println(Unable to load driver.); E.printStackTrace(); } try { //create variable url containing connecting value String url=jdbc:mysql://localhost/weblearn; //Create Connection Object from java.sql.* Connection Conn = DriverManager.getConnection(url, root, ); } //Exceptions if something went wrong catch (SQLException E) { out.println(pSQL Exception/p); } -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Mysql and Tomcat
Greetings All, Just when I though everything was sweet I'm having a nasty problem. I'm running: Debian Linux, Tomcat 4.0.3, Mysql, Ant, MM JDBC driver. Basically I've set everything up sweet and when I run a test file from the command line (java test.class) I get a connection to the database no problems. Unfortunately when I try and do the same thing through a servlet loaded onto Tomcat I get grief!!! See below I get two errors outputted in the browser window, the second one could be caused by the first :-) If anyway has any ideas about this, please let me know this is a desperate one :-((( Thanks heaps and heaps, Gareth Code: try { //Registering the MySQL JDBC Driver Class.forName(org.gjt.mm.mysql.Driver).newInstance(); } catch (Exception E) { out.println(pException: Created Driver/p); System.err.println(Unable to load driver.); E.printStackTrace(); } try { //create variable url containing connecting value String url=jdbc:mysql://localhost/weblearn; //Create Connection Object from java.sql.* Connection Conn = DriverManager.getConnection(url, root, ); } //Exceptions if something went wrong catch (SQLException E) { out.println(pSQL Exception/p); }
connect to MySQL using Tomcat 3.2.1 and Poolman 2.0
I have problems to connect to MySQL using Tomcat 3.2.1 and Poolman 2.0. I use Java Beans to encapsulate information from the JSP's. Formerly I have been using JRun from Allaire and have now changed to Tomcat 3.2.1. JRun was running using the same code. Tomcat Servlet Engine does not allow the same programming style in my Java Beans as JRun did - bad luck. Formerly I had some JB producing result sets within the classes constructor. Tomcat does not seem to allow making a connection, then a statement and then query within the constructor's body. If I call a method from inside the constructor then it works. However, if I want to make a query not at the classes constructor time then I cannot make a connection to the db!!! So I began studying and thought, maybe a pool manager would help and came to Poolman 2.0. No I have problems to make this config running. Please help me and thank you :-) = In Tomcat's server.xml I use the following configuration: RequestInterceptor className=org.apache.tomcat.request.JDBCRealm debug=99 driverName=org.gjt.mm.mysql.Driver connectionURL=jdbc:mysql://localhost/myapp / The org and its subdirectories for the jdbc driver are placed under /webapps/classes which automatically integrates this into classpath = In Poolman's poolman.xml I have use the following conf: dbnamemyappdb/dbname jndiNamejndi_myapp/jndiName driverorg.gjt.mm.mysql.Driver/driver urljdbc:mysql://localhost/myapp?user=myuserpassword=mypassword/url Poolman's files are under /lib ... the /lib/poolman.jar is explicitely in the classpath. If I place the org/ for the jdbc driver under lib too it does also not help. = Here a typical Java Bean without using Poolman: public class Meta { ... private String CONNECTION_URL = jdbc:mysql://localhost/myapp?user=myuserpassword=mypassword; ... public Meta( ) { getMetaData(); } ... private void getMetaData() { try { // The newInstance() call is a work around for some // broken Java implementations Class.forName(org.gjt.mm.mysql.Driver).newInstance(); } catch (Exception E) { System.err.println(Unable to load JDBC driver: org.gjt.mm.mysql.Driver !); E.printStackTrace(); } // load all main Subjects into memory try { Connection conn = DriverManager.getConnection( CONNECTION_URL ); try { Statement qs = conn.createStatement(); ResultSet rs = qs.executeQuery( GET_MAINSUBJECTS ); mainSubjectId = new Vector(); mainSubjectName = new Vector(); mainSubjectMap = new HashMap(); while ( rs.next() ) { mainSubjectId.addElement( rs.getString( MSN_SUBJECT_ID ) ); mainSubjectName.addElement( rs.getString( MSN_NAME ) ); mainSubjectMap.put( rs.getString( MSN_SUBJECT_ID ), rs.getString( MSN_NAME ) ); } // Clean up after ourselves rs.close(); qs.close(); conn.close(); } catch (SQLException E) { System.out.println(1-SQLException: + E.getMessage()); System.out.println(1-SQLState: + E.getSQLState()); System.out.println(1-VendorError: + E.getErrorCode()); E.printStackTrace(); } } catch (Exception E) { E.printStackTrace(); } } o= Here a typical Java Bean using Poolman: public class Meta { ... private String CONNECTION_URL = jdbc:mysql://localhost/myapp?user=myuserpassword=mypassword; ... public Meta( ) { getMetaData(); } ... private void getMetaData() { try { // load the PoolMan JDBC Driver Class.forName(com.codestudio.sql.PoolMan).newInstance(); } catch (Exception ex) { System.out.println(Could Not Find the PoolMan Driver. Is PoolMan.jar in your CLASSPATH?); } Connection con = null; try { // establish a Connection to the database with dbnamemygsk/dbname //in the poolman.xml file con = DriverManager.getConnection(jdbc:poolman://mygsk); // Use the Connection to create Statements and do work, per the JDBC API Statement stm = con.createStatement(); // Get a Connection DataSource ds = PoolMan.findDataSource(jndi_mysql); con = ds.getConnection(); Statement qs = con.createStatement(); ResultSet rs = qs.executeQuery( GET_MAINSUBJECTS ); mainSubjectId = new Vector(); mainSubjectName = new Vector(); mainSubjectMap = new HashMap(); while ( rs.next() ) { mainSubjectId.addElement( rs.getString( MSN_SUBJECT_ID ) ); mainSubjectName.addElement( rs.getString( MSN_NAME
Setup of mysql and tomcat
Could anyone point me in the direction of some documents on setting up mysql with tomcat. I will ream them then ask some questions Thanks all [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: Setup of mysql and tomcat
Hi, write a servlet that accesses mysql put it in tomcat and make an html page to access the servlet. nitin --- Andrew Burrows [EMAIL PROTECTED] wrote: Could anyone point me in the direction of some documents on setting up mysql with tomcat. I will ream them then ask some questions Thanks all [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: How to configure Mysql with Tomcat.
The following code should work if your database's root password is empty: Class.forName(dbDriver).newInstance(); connPool[i]=DriverManager.getConnection("jdbc:mysql://"+dbServer+"?user="+db Login); As for connecting with a non-empty password, I don't know how to do that. If you figure it out, please let me know. --Zeba At 09:58 AM 11/16/00 -0800, Tony Keith wrote: Hello, I wrote a simple servlet to insert a row into a mysql database table. I'm running Tomcat 3.2b7. What are the steps to configure Tomcat to work with this servlet? The problem I'm having now is the driver isn't found. Where do I place the driver? In the lib directory? How do I reference a new instance of the driver? This is how I reference it now: Class.forName("org.mm.mysql.Driver").newInstance(); Will the connection information remain the same? Here is the connection information I currently use: con = DriverManager.getConnection("jdbc:mysql://localhost/webdata", "user", "password"); TIA -- Tony Keith
Re: How to configure Mysql with Tomcat.
Zebadiah Kimmel wrote: The following code should work if your database's root password is empty: Class.forName(dbDriver).newInstance(); My problem is the driver isn't being loaded. Configuration problems, I believe... connPool[i]=DriverManager.getConnection("jdbc:mysql://"+dbServer+"?user="+db Login); As for connecting with a non-empty password, I don't know how to do that. If you figure it out, please let me know. --Zeba At 09:58 AM 11/16/00 -0800, Tony Keith wrote: >Hello, > >I wrote a simple servlet to insert a row into a mysql database table. >I'm running Tomcat 3.2b7. > >What are the steps to configure Tomcat to work with this servlet? >The problem I'm having now is the driver isn't found. > >Where do I place the driver? In the lib directory? > >How do I reference a new instance of the driver? >This is how I reference it now: >Class.forName("org.mm.mysql.Driver").newInstance(); > >Will the connection information remain the same? >Here is the connection information I currently use: >con = DriverManager.getConnection("jdbc:mysql://localhost/webdata", >"user", "password"); > >TIA >-- >Tony Keith -- Tony Keith Director of Information Technology Paycom.net 4215 Glencoe Avenue, First Floor Marina Del Rey, CA 90292 TEL: (310) 827-5880 ext. 304 FAX: (310) 827-5519
Re: How to configure Mysql with Tomcat.
For Tomcat 3.2b6 I used: my setup: Apache 1.3.12 RH 6.2 Linux 2.2.14-5.0 Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DatabaseName?user=dbuserpassword=dbpassword"); put the jdbc drivers in the classes folder of your app like: cp -Rf $JDBC_HOME/org $MYAPP_HOME/WEB-INF/classes That should do it, but I have noticed serious performance degradation in switching from JServ 1.1.2 to Tomcat 3.2b6. I am not sure if I am missing something in the docs, but JServ 1.1.2/GNUJsp 1.0 is IMHO much faster (at least with the mm.mysql JDBC driver apps I have written) If someone could point me to some tuning tips/parameters I may have missed in the standard docs I would really appreciate it. Noel - Original Message - From: Zebadiah Kimmel [EMAIL PROTECTED] Sent: Thu, 16 Nov 2000 13:49:07 -0500 To : [EMAIL PROTECTED],[EMAIL PROTECTED] Subject : Re: How to configure Mysql with Tomcat. The following code should work if your database's rootpassword is empty: Class.forName(dbDriver).newInstance(); connPool[i]=DriverManager.getConnection("jdbc:mysql://"+dbServer+"?user="+db Login); As for connecting with a non-empty password, I don'tknow how to do that. If you figure it out, please let me know. --Zeba At 09:58 AM 11/16/00 -0800, Tony Keith wrote: Hello, I wrote a simple servlet to insert a row into a mysqldatabase table. I'm running Tomcat What are the steps to configure Tomcat to work withthis servlet? The problem I'm having now is the driver isn't found. Where do I place the driver? In the lib directory? How do I reference a new instance of the driver? This is how I reference it now: Class.forName("org.mm.mysql.Driver").newInstance(); Will the connection information remain the same? Here is the connection information I currently use: con =DriverManager.getConnection("jdbc:mysql://localhost/webdata", "user", "password"); TIA -- Tony Keith __ Move your email to a better address. Over 1,000 domains to choose from! FREE! PRIVATE! http://www.MailSpace.com
Re: How to configure Mysql with Tomcat.
Noel Morgan wrote: For Tomcat 3.2b6 I used: my setup: Apache 1.3.12 RH 6.2 Linux 2.2.14-5.0 Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DatabaseName?user=dbuserpassword=dbpassword"); put the jdbc drivers in the classes folder of your app like: cp -Rf $JDBC_HOME/org $MYAPP_HOME/WEB-INF/classes I tried this but I still get the same error... Is there any other configuration to the web.xml? That should do it, but I have noticed serious performance degradation in switching from JServ 1.1.2 to Tomcat 3.2b6. I am not sure if I am missing something in the docs, but JServ 1.1.2/GNUJsp 1.0 is IMHO much faster (at least with the mm.mysql JDBC driver apps I have written) If someone could point me to some tuning tips/parameters I may have missed in the standard docs I would really appreciate it. Noel - Original Message - >From : Zebadiah Kimmel [EMAIL PROTECTED]> Sent : Thu, 16 Nov 2000 13:49:07 -0500 To : [EMAIL PROTECTED],[EMAIL PROTECTED] Subject : Re: How to configure Mysql with Tomcat. The following code should work if your database's rootpassword is empty: Class.forName(dbDriver).newInstance(); connPool[i]=DriverManager.getConnection("jdbc:mysql://"+dbServer+"?user="+db Login); As for connecting with a non-empty password, I don'tknow how to do that. If you figure it out, please let me know. --Zeba At 09:58 AM 11/16/00 -0800, Tony Keith wrote: >Hello, > >I wrote a simple servlet to insert a row into a mysqldatabase table. >I'm running Tomcat > >What are the steps to configure Tomcat to work withthis servlet? >The problem I'm having now is the driver isn't found. > >Where do I place the driver? In the lib directory? > >How do I reference a new instance of the driver? >This is how I reference it now: >Class.forName("org.mm.mysql.Driver").newInstance(); > >Will the connection information remain the same? >Here is the connection information I currently use: >con =DriverManager.getConnection("jdbc:mysql://localhost/webdata", >"user", "password"); > >TIA >-- >Tony Keith __ Move your email to a better address. Over 1,000 domains to choose from! FREE! PRIVATE! http://www.MailSpace.com -- Tony Keith Director of Information Technology Paycom.net 4215 Glencoe Avenue, First Floor Marina Del Rey, CA 90292 TEL: (310) 827-5880 ext. 304 FAX: (310) 827-5519
Re: How to configure Mysql with Tomcat.
Tony, I tried this but I still get the same error... Is there any other configuration to the web.xml? Have you tried unpacking the jar under your /WEB-INF/classes directory? You'll end up with something like classes/org/gjt/mm/mysql/ Either that or putting the jar (not just the jar's path) in the classpath should do the job. Dave Dave Harms [EMAIL PROTECTED]
Re: How to configure Mysql with Tomcat. (problem Fixed!)
Tony Keith wrote: Once I copied the Mysql classes to the /WEB-INF/classes directory it worked. I also was specifying the wrong path for the driver. I had org.mm.mysql.Driver instead of org.gjt.mm.mysql.Driver. Thanks for everyone's help. Noel Morgan wrote: For Tomcat 3.2b6 I used: my setup: Apache 1.3.12 RH 6.2 Linux 2.2.14-5.0 Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DatabaseName?user=dbuserpassword=dbpassword"); put the jdbc drivers in the classes folder of your app like: cp -Rf $JDBC_HOME/org $MYAPP_HOME/WEB-INF/classes I tried this but I still get the same error... Is there any other configuration to the web.xml? That should do it, but I have noticed serious performance degradation in switching from JServ 1.1.2 to Tomcat 3.2b6. I am not sure if I am missing something in the docs, but JServ 1.1.2/GNUJsp 1.0 is IMHO much faster (at least with the mm.mysql JDBC driver apps I have written) If someone could point me to some tuning tips/parameters I may have missed in the standard docs I would really appreciate it. Noel - Original Message - >From : Zebadiah Kimmel [EMAIL PROTECTED]> Sent : Thu, 16 Nov 2000 13:49:07 -0500 To : [EMAIL PROTECTED],[EMAIL PROTECTED] Subject : Re: How to configure Mysql with Tomcat. The following code should work if your database's rootpassword is empty: Class.forName(dbDriver).newInstance(); connPool[i]=DriverManager.getConnection("jdbc:mysql://"+dbServer+"?user="+db Login); As for connecting with a non-empty password, I don'tknow how to do that. If you figure it out, please let me know. --Zeba At 09:58 AM 11/16/00 -0800, Tony Keith wrote: >Hello, > >I wrote a simple servlet to insert a row into a mysqldatabase table. >I'm running Tomcat > >What are the steps to configure Tomcat to work withthis servlet? >The problem I'm having now is the driver isn't found. > >Where do I place the driver? In the lib directory? > >How do I reference a new instance of the driver? >This is how I reference it now: >Class.forName("org.mm.mysql.Driver").newInstance(); > >Will the connection information remain the same? >Here is the connection information I currently use: >con =DriverManager.getConnection("jdbc:mysql://localhost/webdata", >"user", "password"); > >TIA >-- >Tony Keith __ Move your email to a better address. Over 1,000 domains to choose from! FREE! PRIVATE! http://www.MailSpace.com -- Tony Keith Director of Information Technology Paycom.net 4215 Glencoe Avenue, First Floor Marina Del Rey, CA 90292 TEL: (310) 827-5880 ext. 304 FAX: (310) 827-5519 -- Tony Keith Director of Information Technology Paycom.net 4215 Glencoe Avenue, First Floor Marina Del Rey, CA 90292 TEL: (310) 827-5880 ext. 304 FAX: (310) 827-5519
RE: How to configure Mysql with Tomcat.
Hi, I place the MySQL drivers in my WEB-INF/lib directory (in their JAR file) and I make sure that it is in my classpath. You can check your class path if you place this code into a servlet (it is writing to the response's writer): Properties sysProp = System.getProperties(); Enumeration propNames = sysProp.propertyNames(); while (propNames.hasMoreElements()) { String name = (String)propNames.nextElement(); out.print(name); out.print("="); out.println(sysProp.getProperty(name)); } I use the driver this way: Class.forName("org.gjt.mm.mysql.Driver"); Connection dbConn = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "username", "password"); So, the problem might be the name of the driver that you are using (I noticed that you do not have a gjt in your driver name). I got my drivers from the MySQL website: http://www.mysql.com/ Allen You wrote: - Hello, I wrote a simple servlet to insert a row into a mysql database table. I'm running Tomcat 3.2b7. What are the steps to configure Tomcat to work with this servlet? The problem I'm having now is the driver isn't found. Where do I place the driver? In the lib directory? How do I reference a new instance of the driver? This is how I reference it now: Class.forName("org.mm.mysql.Driver").newInstance(); Will the connection information remain the same? Here is the connection information I currently use: con = DriverManager.getConnection("jdbc:mysql://localhost/webdata", "user", "password"); TIA -- Tony Keith
Where to put JDBC drivers? (Was How to configure Mysql with Tomcat.)
Tony Keith [EMAIL PROTECTED] wrote: snip Noel Morgan wrote: For Tomcat 3.2b6 I used: my setup: Apache 1.3.12 RH 6.2 Linux 2.2.14-5.0 Class.forName("org.gjt.mm.mysql.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/DatabaseName?user=dbuserpassword=dbpassword"); put the jdbc drivers in the classes folder of your app like: cp -Rf $JDBC_HOME/org $MYAPP_HOME/WEB-INF/classes I tried this but I still get the same error... Is there any other configuration to the web.xml? I'm having a similar problem getting JDBCRealm, following the JDBCRealm HOWTO, to work on Tomcat 3.2b7 on Apache 1.3.12 and NT 4.0. I'm using the inet Type 4 driver with a user database in SQL Server 7. When I try to start Tomcat, it fails, and the jvm.stderr log contains the following: 2000-11-16 04:33:01 - ContextManager: Adding context Ctx( /examples ) 2000-11-16 04:33:01 - ContextManager: Adding context Ctx( /admin ) 2000-11-16 04:33:01 - ContextManager: Adding context Ctx( ) 2000-11-16 04:33:01 - ContextManager: Adding context Ctx( /simple ) 2000-11-16 04:33:01 - ContextManager: Adding context Ctx( /test ) java.lang.RuntimeException: JDBCRealm.start.readXml: java.lang.ClassNotFoundException: com.inet.tds.TdsDriver at org.apache.tomcat.request.JDBCRealm.contextInit(JDBCRealm.java:434) at org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:493) at org.apache.tomcat.core.ContextManager.init(ContextManager.java:453) at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:197) at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:237) and jvm.stdout has Starting tomcat. Check logs/tomcat.log for error messages FATAL:java.lang.RuntimeException: JDBCRealm.start.readXml: java.lang.ClassNotFoundException: com.inet.tds.TdsDriver There is nothing in tomcat.log. I've opened the driver jar file, and the TdsDriver class is definitely in there, and I get the same error whether I put the jar in TOMCAT_HOME/lib or in WEB-INF/lib or in WEB-INF/classes. I've even tried adding it to my CLASSPATH and rebooting. I wrote a little java console program to test the driver and it works fine by running it with the -classpath option. Thanks for any suggestions. Larry P.S. Here's the relevant portion of server.xml: !-- Check if the request requires an authenticated role. -- RequestInterceptor className="org.apache.tomcat.request.AccessInterceptor" debug="0" / !-- Check permissions. -- RequestInterceptor className="org.apache.tomcat.request.JDBCRealm" debug="99" driverName="com.inet.tds.TdsDriver" connectionURL="jdbc:inetdae:localhost:1433?database=AppSecurity" userTable="users" userNameCol="user_name" userCredCol="user_pass" userRoleTable="user_roles" roleNameCol="role_name" /