Create database postgresql using JAVA -
hello want create database postgresql using java got error message here code :
try { connection c=null; statement stmt=null; class.forname("org.postgresql.driver"); c = drivermanager .getconnection("jdbc:postgresql://localhost:5432/", "postgres", "admin@2014"); c.setautocommit(false); system.out.println("opened database successfully"); stmt = c.createstatement(); string sql = "create database db owner postgres tablespace numerique; "; stmt.executeupdate(sql); stmt.close(); c.commit(); c.close(); } catch (exception ee) { system.err.println( ee.getclass().getname()+": "+ ee.getmessage() ); system.exit(0); }
and here error message got :
org.postgresql.util.psqlexception: erreur: create database ne peut pas être exécuté dans un bloc de transaction
thank you're help
remove c.setautocommit(false);
, c.commit();
code.
Comments
Post a Comment