• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling command prompt from java  RSS feed

 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to open command prompt from java program and run the following command :

"sqlcmd -S servername -d databasename -i C:\mysqlfile.sql"

I tried n number of ways but was not able to find a solution.

I tried the followinf code but didnt work:



Can someone help.

Thanks in advance.

Girish
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by “didn’t work”? If you want help you must supply the details.
 
Girish Kumar Prabhakar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By 'didn't work' , I meant that I was not able to run the command successfully.

However, thanks for your reply.

I figured it out.

The problem was that in the second argument "/c ", there was an extra space and third argument is not required. You do not need to write "start" argument.

So this will work :



Thanks
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Girish Kumar Prabhakar wrote:By 'didn't work' , I meant that I was not able to run the command successfully.

Which is simply the same statement using different words, and equally useless.

If you want help, you need to TellTheDetails (←click), and that means supplying actual messages and context; otherwise we're simply floundering around even worse than you are.

I would also add that, whether it works or not, running a database server start-up from Java is probably not the best choice. If the database provides a Java-based API to do it, I'd use that; if not, it's probably a task best left to your admins (and I certainly wouldn't use Java).

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!