Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: ReplicationDriver & PreparedStatement


Advanced Search

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 david TENTE 09/13/2012 06:37AM
Re: ReplicationDriver & PreparedStatement Todd Farmer 09/13/2012 09:07AM
Re: ReplicationDriver & PreparedStatement david TENTE 09/13/2012 09:34AM
Re: ReplicationDriver & PreparedStatement Todd Farmer 09/13/2012 09:37AM
Re: ReplicationDriver & PreparedStatement david TENTE 09/13/2012 09:42AM
Re: ReplicationDriver & PreparedStatement Todd Farmer 09/19/2012 08:32AM
Re: ReplicationDriver & PreparedStatement david TENTE 09/19/2012 08:47AM
Re: ReplicationDriver & PreparedStatement Dinesh Varyani 09/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.