• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to create database in ms-sql server using java/jdbc

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

this is siva and this is my situation..
i need to create a database in ms-sql server using java/jdbc .the database creation script will be in .sql file.

we can create the database with the help of osql commands if the local system is installed with ms-sql server.

but i need to create the database on the remote system without ms-sql server installed in my local system.
 
Ranch Hand
Posts: 349
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You can try using JTDS API for your needs. This is available in source forge which enables communication from Java to ms-sql.

Ananth Chellathurai
 
siva krishna pallapu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks ananth,

can you please post the url it would be very helpful to me if you do this..
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll find this information in the jTDS documentation.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you can create databases using JDBC. The JDBC URL already contains the name of the database to connect to, after all.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wondered that too. With SQL Server I'd try connecting to the master database (which always exits) as sa. That should work?
 
siva krishna pallapu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah you are right mr.ulf mitter ..
but my requirement is to create a database using java or any other api it can be either with .bat files also but the local system should not contain any servers installed in it..

for ex:
let us say if the local system contains ms-sql server then we can create the databases on remote systems using osql commands.. but this is not not my situation local system will not have any servers installed on it.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you use Telnet to log into the other machine? If so, you can use the Apache Commons Net library (which contains a Telnet client) to run osql on the server itself. Using SSH instead of Telnet would also be an option.

But in general I would say that the creation of a database should be a sufficiently rare occasion that it doesn't need to be automated to this degree. How often do you foresee running this?
[ September 15, 2008: Message edited by: Ulf Dittmer ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic