Salve,
volevo inserire un controllo in un applicazione che mi consentisse di creare le tabelle di un db se il db stesso non è stato ancora creato, pensavo di fare come segue:
potrebbe andare secondo voi come sistema?codice:public ResultSet prelevaDb(String nometab){ ResultSet rs=null; try{ rs=this.st.executeQuery("SELECT * FROM "+nometab); } catch(SQLException es){ if(es.getErrorCode()==30000){ this.inizializzaDB(); try{ rs=this.st.executeQuery("SELECT * FROM "+nometab); } catch(SQLException e){ System.err.println(e.getErrorCode()+"\n"+e.getMessage()); } } else System.err.println("Errore nel recupero delle tabelle:"+es.getErrorCode()+"\n"+es.getMessage()); } return rs; } public void inizializzaDB(){ try{ this.st.execute("CREATE TABLE ANAGRAFICA(ID_R INTEGER NOT NULL PRIMARY KEY,NAME_R VARCHAR(100),INDIRIZZO VARCHAR(250))"); } catch(SQLException e){ System.err.println(e.getErrorCode()+"\n"+e.getMessage()); } }

Rispondi quotando