my dog learned polymorphism*
The moose likes JDBC and the fly likes DDL & DML executor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DDL & DML executor" Watch "DDL & DML executor" New topic
Author

DDL & DML executor

jeff rusty
Ranch Hand

Joined: Nov 07, 2006
Posts: 109
Hi ranchers,

I am trying to set up an installer for my application and in that i have to ask the user for the database he want to use for the application and the database parameters like URL,username and password.
So i wish to know if java can create a database user for the selected database and execute the application specific SQL scripts based on the given parameters. Also let me know if there are any other API which is available to do this?


thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Jeff,
The user would already exist, correct? If so, yes you can create a connection using a specified user id and password. The standard JDBC provides a method for this.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jeff rusty
Ranch Hand

Joined: Nov 07, 2006
Posts: 109
Yes i can create a connection with those details but i need to do a execute update for each statement but i am expecting something like passing an SQL script file which has the table & constraint creation scripts.

thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Jeff,
If you want to pass a script, you are better off using Runtime.exec and doing it at the command line.
jeff rusty
Ranch Hand

Joined: Nov 07, 2006
Posts: 109
thank you.

could you please explain that in little detail. Tell me how to handle oracle and SQL server databse dynamically based on the user parameter.

thanks
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

What part are you having trouble with:
1) Determining a user parameter
2) Writing a command line to run a sql file
3) Calling runtime exec
 
jQuery in Action, 2nd edition
 
subject: DDL & DML executor