• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
siva krishna pallapu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.
 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks ananth,

can you please post the url it would be very helpful to me if you do this..
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll find this information in the jTDS documentation.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic