Has anyone ever found a way to connect to a DBMS without specifying the Database Name initially? I know that doesn't make sense because of the way a Connection works in JDBC. But here is a possible scenerio that may help. What if someone deletes all the Databases in an SQL database? Is there no way in JAVA using JDBC to connect to the DBMS and create a new one? Also, I know that with MySQL I can always choose test or MySQL by default. And with MS SQL Northwind is a safe bet. But can someone tell me some other defaults for some of the other DBMS' out there. Like Oracle, Postgre, etc? Thanks
Joined: Dec 04, 2001
You can definitely use jdbc to connect to a database and create a new instance. Look around for java database management tools. While I am not certain as to whether this works or not, this is how would envision doing it: 1. Create a Connection to the database 2. Create a Statement object 3. Use the statement object to execute your database creation query/script. Give it a try and see how it works.
Did you read my question? The JDBC API specifies that when creating a Connection object, you have to specify the Database Name to Connect to. I know I can connect to a Database then do a "USE" command to specify another database after I have created it. However, what if there are no databases created? Then what do you provide in the Connection object to create a Connection if it requires a DB name? Thanks for responding though.