File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to create database in ms-sql server using java/jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to create database in ms-sql server using java/jdbc" Watch "how to create database in ms-sql server using java/jdbc" New topic
Author

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

siva krishna pallapu
Greenhorn

Joined: Aug 12, 2008
Posts: 7
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

Joined: Nov 21, 2007
Posts: 349

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


Ananth Chellathurai [Walk on software]
siva krishna pallapu
Greenhorn

Joined: Aug 12, 2008
Posts: 7
thanks ananth,

can you please post the url it would be very helpful to me if you do this..
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You'll find this information in the jTDS documentation.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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.


Ping & DNS - my free Android networking tools app
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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

Joined: Aug 12, 2008
Posts: 7
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
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create database in ms-sql server using java/jdbc