Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

DDL & DML executor

 
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
 
author & internet detective
Posts: 39997
807
Eclipse IDE VI Editor Java
  • 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
Posts: 39997
807
Eclipse IDE VI Editor Java
  • 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
Posts: 39997
807
Eclipse IDE VI Editor Java
  • 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
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic