0
I am creating a form in Jframe to insert data into a table that contains two foreign keys (since these keys are not generated automatically).
What I have to put on Insert to get foreign keys?
public void inserir(Tratamento tratamento) {
try{
try (Connection conexao = getConexao(); PreparedStatement stmt = conexao.prepareStatement("insert into tratamento "
+ "(codigo_tratamento, titulo, descricao) "
+ "values (?,?,?)")) {
stmt.setString(1, tratamento.getCodigo_tratamento());
stmt.setString(2, tratamento.getTitulo());
stmt.setString(3, tratamento.getDescricao());
stmt.execute();
}
}catch(SQLException e){
}
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
I did not understand the question, do you want to fill two columns (which are foreign keys) of the treatment table? Or want to fetch the keys (sub-select) and fill in the Insert? You have something that identifies the two records of these relationships (Inner Join)?
– Wakim
Fetch keys and fill in the Insert.
– Emanuella Gomes
What would be the ideal elements of Jframe to make the selection of the element?
– Emanuella Gomes