Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Create if not exists a new Java DB?

Tags:

java

database

 conn = DriverManager.getConnection("jdbc:derby:mydatabase;create=true",props);

will this line make my DB get overwritten everytime i execute it? if it will how do i create the DB once and just use it ever since?

like image 391
Ofek Ron Avatar asked Oct 14 '12 12:10

Ofek Ron


People also ask

What is create table if not exists SQL?

CREATE TABLE IF NOT EXISTS. If the IF NOT EXISTS clause is used, then the table will only be created if a table with the same name does not already exist. If the table already exists, then a warning will be triggered by default.


1 Answers

What you are doing will work with Derby. It will create the database if it doesn't exist and do nothing if it already does exist.

like image 85
Shawn D. Avatar answered Oct 15 '22 19:10

Shawn D.