Bonjour,
tout est dans le titre.

J'ai crée deux base mysql en réplication, puis je veux tester si je bascule bien entre mon master et mon slave sauf que je récupère un ClassCastException sur les PreparedStatement ligne 25.

Est-ce un bug du connecteur Mysql ??
Ou un oubli dans la configuration du driver ??

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
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("");
		}
 
	}