[ https://issues.apache.org/jira/browse/DBCP-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12466739 ]
Niall Pemberton commented on DBCP-208: -------------------------------------- So it looks like you need to encode the amersand in your XML configuration, otherwise the XML parser thinks sessionVariables is an encoded entity - try changing the "&" to "&" jdbc:mysql://localhost:3316/db?transformedBitIsBoolean=true&[EMAIL PROTECTED]'0',@version='1.0'; > URL Parsing Bug > --------------- > > Key: DBCP-208 > URL: https://issues.apache.org/jira/browse/DBCP-208 > Project: Commons Dbcp > Issue Type: Bug > Environment: Tomcat DBCP > Reporter: Ricotta > Priority: Minor > Fix For: 1.3 > > > Hello, > I think there's a bug at the > org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory at the time of parsing a > certain MySQL url. When the connection url contains the "sessionVariables" > property alone, everything works ok. However, when other properties are > specified in addition to "sessionVariables", then an Exception is thrown when > trying to establish a new connection. If the same url is specified using a > Connection object inside my code, then NO error is thrown. It only happens > when that same url is set at the Resource config of the server.xml file. I > include some examples to reproduce the error: > Everything goes fine when this is the config of the resource (note that the > important part is the url): > <Resource name="jdbc/db" auth="Container" type="javax.sql.DataSource" > factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" > maxActive="15" > maxIdle="5" > validationQuery="SELECT 1" > testOnBorrow="false" > testWhileIdle="true" > timeBetweenEvictionRunsMillis="10000" > minEvictableIdleTimeMillis="60000" > username="user" > password="pass" > driverClassName="com.mysql.jdbc.Driver" > url="jdbc:mysql://localhost:3316/[EMAIL PROTECTED]'0',@version='1.0';" > /> > However, if we set this other url in the previous example, an error will be > printed on the tomcat's log file: > jdbc:mysql://localhost:3316/db?transformedBitIsBoolean=true&[EMAIL > PROTECTED]'0',@version='1.0'; > It seems to be a bug when sessionVariables is specified in addition to other > properties, like transformedBitIsBoolean in the previous example. > As I mentioned above, when this same url is set using a Connection object > inside my application, no Exception is thrown, so I think the bug is located > at the BasicDataSourceFactory class. > This is the exception thrown: > org.xml.sax.SAXParseException: The reference to entity "sessionVariables" > must end with the ';' delimiter. > at > org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown > Source) > at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) > at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source) > at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown > Source) > at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561) > at org.apache.catalina.startup.Catalina.load(Catalina.java:489) > at org.apache.catalina.startup.Catalina.start(Catalina.java:543) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) > This is the code I've used to test the same URL, but establishing a new > Connection object inside my application: > Class.forName("com.mysql.jdbc.Driver").newInstance(); > Connection > connection=DriverManager.getConnection("jdbc:mysql://localhost:3316/db?transformedBitIsBoolean=true&[EMAIL > PROTECTED]'0',@version='1.0';"); > As you can see, the URL is the same in both cases. However, now that I'm > looking at the Exception in detail, the bug seems to be at the > org.apache.tomcat.util.digester.Digester.parse method and not in the DBCP. > Sorry if that's the case. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]