public C[] getC() throws SQLException, ClassNotFoundException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Mydb";
String user = "user1";
String password = "password";
Connection con = DriverManager.getConnection(url,user,password);
Statement smt= con.createStatement();
String query = "Select ssn, cname from customer";
ResultSet rs = smt.executeQuery(query);
C [] c = new C[getNumberOfCustomers()];
while (rs.next()){
String ssn = rs.getString("ssn");
String customer_name = rs.getString("cname");
}
return custarray;
}
Cのコードは次のとおりです。
public class C {
private String name;
private String SocialSecurityNumber;
public C(String name, String SocialSecurityNumber) {
this.name = name;
this.SocialSecurityNumber = SocialSecurityNumber;
}
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getSocialSecurityNumber() { return SocialSecurityNumber; }
public void setSsn(String SocialSecurityNumber ) {
this.SocialSecurityNumber = SocialSecurityNumber;
}
}
ここで、ssn と customer_name をC[]
配列に渡す際に問題が発生しています