Can anyone help me with this? I've read through http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-replication-connection.html and created a JBoss datasource with
<connection-url>jdbc:mysql:replication://sys1:3306,sys2:3306,sys3:3306/mydb</connection-url>
<driver-class>com.mysql.jdbc.ReplicationDriver</driver-class>
In my JBoss code, when I execute the following (on a slave node)
Context initCtx = new InitialContext();
DataSource ds = (DataSource) initCtx.lookup( ... );
conn = ds.getConnection();
conn.setReadOnly( false );
conn.prepareStatement( ... );
The prepareStatement call produces the following stack trace:
2010-09-16 18:45:31,129 WARN [org.jboss.resource.connectionmanager.TxConnectionManager] (ajp-127.0.0.1-8009-2) Connection error occured: org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener@1b576f8[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@11a3ce4 handles=1 lastUse=1284659131129 permit=true trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@193a581 context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@56e1fe xaResource=org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@f058a txSync=null]
java.lang.ClassCastException: $Proxy297
at com.mysql.jdbc.ReplicationConnection.prepareStatement(ReplicationConnection.java:357)
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:465)
at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:460)
at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:243)
at com.mycode.service.Kernel.doGet(Kernel.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:384)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
I've looked around for answers but can't find anyone with a similar problem. Am I missing the obvious???
Thanks