java - How can I switch the database context of an existing DataSource? -


let's have existing datasource master database. need create new database, , execute ddls on database. possible e.g, "use" command, or need create new datasource name of new database in jdbc url?

you can run "use" command regular jdbc statement.

statement stmt = connection.createstatement(); stmt.execute("use the_other_db"); 

dependending on dbms , driver might able use jdbc api call setcatalog():

connection.setcatalog("the_other_db") 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -