나는 다음과 같은 오류가 포스트 그레스에 자바 배열을 삽입하고 얻기 위해 노력하고 아래자바 배열 삽입
Exception in thread "main" org.postgresql.util.PSQLException: No value specified for parameter 2
코드 : 두 번째 ps.setObject()
가 처음 설정이야에서
public static void main(String[] args) throws SQLException {
String sku = "1";
String[] cross = { "0514", "0414", "0314", "0214", "0114", "1213", "1113",
"1013", "0913", "0813", "0713", "0613" };
String sqlString = "Insert into dbo.Inventory_Metrics skus, cross values(?,?)";
Connection conn = DriverManager.getConnection(getPostgresConnUrl());
PreparedStatement ps = conn.prepareStatement(sqlString);
ps.setObject(1, sku);
ps.setObject(1, cross, java.sql.Types.VARCHAR, cross.length);
//This next line throws the error
int status = ps.executeUpdate();
ps.close();
System.out.print(status);
}
public static String getPostgresConnUrl() {
String database = "mycode";
String userName = "xxxxxxxx";
String password = "xxxxxxxx";
return "jdbc:postgresql://xxx.xxx.xxx.xxx:xxxx/" + database + "?user=" +
userName + "&password=" + password;
}
오타가해야 두 번
첫 번째 매개 변수의 값을 반복하고 있습니다. 첫 번째 매개 변수를 두 번 설정하고 있습니다. – lifus