wood burning stoves 2.0*
The moose likes JDBC and the fly likes How to create SQL server2005 database on remote machine using 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 SQL server2005 database on remote machine using jdbc?" Watch "How to create SQL server2005 database on remote machine using jdbc?" New topic
Author

How to create SQL server2005 database on remote machine using jdbc?

Praveen Kumarji
Greenhorn

Joined: Mar 28, 2011
Posts: 5
hi i am creating a desktop application, in which i have to login into sql server 2005 on the remote machine & have to create database, User etc, by using jTDS i am able to create connection to database as well as able to execute "SELECT" commnads but not able to execute database commands like- create database, create user etc.

can any one guide me how do i do this?
Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You should be able to execute DDL statements. What happened when you tried? Did you get an error message?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Praveen Kumarji
Greenhorn

Joined: Mar 28, 2011
Posts: 5
yes i am getting error
java.sql.SQLException: CREATE DATABASE permission denied in database 'master'.


here is my test code-
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The user you connect with does not have permission to create databases. Speak to your SQL Server admin.
Praveen Kumarji
Greenhorn

Joined: Mar 28, 2011
Posts: 5
yes I knew that, but my problem is that I have to prepare database on remote machine (which will be having SQL server 2005 installed on it and i have to login into that using window authentication) for the use of my application (creation of user and database) by using JDBC only.

can you please suggest how my user can be added to database as sysadmin role, or any other idea if you have? I think using SQL CMD it is possible but dont know how!!!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

...can you please suggest how my user can be added to database as sysadmin role, or any other idea if you have? I think using SQL CMD it is possible but dont know how...

Your DB admin should create a user/add the privilege to an existing user. You should talk to your SQL server admin as Paul suggested.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You don;t need a user in sysadmin role to create databases, the user just needs that specific operation granted to them. You can alter your user via T-SQL (run from Java code if needs be) but my guess is you will probably not have permission to do that either. Speaking to your database admin will speed this process up no end.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to create SQL server2005 database on remote machine using jdbc?
 
Similar Threads
simple mysql questoion
JDBC Type 4 Drivers
RMI and Oracle's Jserver VM
changes not refelected in Oracle10g RAC database
problem in logging