Hello, I have this part of the code:
public void inserir(Assignatura as) throws GestorException {
//TODO codificar el metode inserir
String sentenciaSQL = null;
PreparedStatement elm = null;
try{
elm = con.prepareStatement(sentenciaSQL);
// elm = con.prepareStatement("INSERT INTO assignatura (codi, assignatura, dies");
sentenciaSQL = "INSERT INTO assignatura VALUES (1, "
+"'Mates','dilluns')";
elm.executeUpdate(sentenciaSQL);
//elm.setObject(1,as);
//elm.executeUpdate();
} catch (SQLException ex){
System.out.println("error!"+ex.getMessage());
System.out.println("SQLsState:"+ ex.getSQLState());
}finally{
try {
if(elm!=null && !elm.isClosed()){
elm.close();
}
} catch (SQLException ex) {/*llàstima!*/}
try {
if(con!=null && !con.isClosed()){
con.close();
}
} catch (SQLException ex) {
Logger.getLogger(GestorAssignatura.class.getName()).log(Level.SEVERE, null, ex);
}
}
I'm trying things out but I do not know 100% how to do it .. the sql is this:
CREATE TYPE dades_assignatura as (nom character varying(30), hores integer);
CREATE TABLE Assignatura
(
codi integer NOT NULL,
assignatura dades_assignatura,
dies character varying(9)[],
CONSTRAINT clauPrimariaAssignatura PRIMARY KEY (codi)
)
WITH (
OIDS=FALSE
);
ALTER TABLE Assignatura
OWNER TO postgres;
I'm going crazy ... I do not know 100% how it's done and I do not find information either: (