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("");
}

}

Options: ReplyQuote


Subject
Written By
Posted
ReplicationDriver & PreparedStatement
September 13, 2012 06:37AM


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.