• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Calling command prompt from java

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 76887
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic