我有一組數組值,我想插入到數據庫中,但它出來的結果是我不想要的。將數組值插入數據庫postgresql
我希望我的數據庫可以存儲這樣的:
id_code | id_description
---------------------------
PO1 | hello
PO2 | hi
但我運行的代碼,其存儲這樣的:
id_code | id_description
-----------------------------------
[PO1,P02] | [hello, hi]
這裏是編碼:
public void addID(IDInfo IDInformation) {
try {
PreparedStatement preparedStatement = connection
.prepareStatement("INSERT INTO id (id_code, id_description)"
+ "VALUES (?, ?)");
preparedStatement.setString(1, Arrays.toString(IDInformation.getIDCode()));
preparedStatement.setString(2, Arrays.toString(IDInformation.getIDDescription()));
preparedStatement.executeUpdate();
}
}
catch (SQLException e){
e.printStackTrace();
}
}
控制器:
String action = request.getParameter("action");
IDInfo idInfo = new IDInfo();
String[] Code = request.getParameterValues("idCode");
String [] Describe = request.getParameterValues("idDescription");
idInfo.setidCode(Code);
idInfo.setidDescription(Describe);
這是怎麼引起的,我該如何解決?