ReplicationDriver & PreparedStatement
Posted by:
david TENTE
Date: September 13, 2012 06:37AM
Hello,
I have a ClassCastException when I use a PreparedStatement with the replicationDriver ?
Any idea what's wrong ?
StackTrace:
Exception in thread "main" java.lang.ClassCastException: $Proxy4
at com.mysql.jdbc.ReplicationConnection.prepareStatement(ReplicationConnection.java:328)
My Code:
public static void main(String[] args) throws SQLException {
ReplicationDriver driver = new ReplicationDriver();
Properties props = new Properties();
// We want this for failover on the slaves
props.put("autoReconnect", "true");
props.put("roundRobinLoadBalance", "true");
props.put("user", Constants.USER);
props.put("password", Constants.PASSWORD);
Connection conn = driver.connect(Constants.URL,props);
conn.setReadOnly(true);
ResultSet rs = conn.createStatement().executeQuery("Select * from activity");
int numcols = rs.getMetaData().getColumnCount();
while(rs.next()) {
for(int i=1;i<=numcols;i++) {
System.out.print("\t" + rs.getString(i));
}
System.out.println("");
}
rs = conn.prepareStatement("Select * from activity").executeQuery();
numcols = rs.getMetaData().getColumnCount();
while(rs.next()) {
for(int i=1;i<=numcols;i++) {
System.out.print("\t" + rs.getString(i));
}
System.out.println("");
}
}
Subject
Written By
Posted
ReplicationDriver & PreparedStatement
September 13, 2012 06:37AM
September 13, 2012 09:07AM
September 13, 2012 09:34AM
September 13, 2012 09:37AM
September 13, 2012 09:42AM
September 19, 2012 08:32AM
September 19, 2012 08:47AM
September 26, 2012 03:27AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.