Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DDL & DML executor

 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jeff rusty
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic