Get your CodeRanch badge!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DDL & DML executor
 
Similar Threads
Applet displays grey box, but applet is started
DDL & DML executor
NX: About the db file
How to change the database in Java EE
hide parameters on url jsp