• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
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 should be able to execute DDL statements. What happened when you tried? Did you get an error message?
 
Praveen Kumarji
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i am getting error

java.sql.SQLException: CREATE DATABASE permission denied in database 'master'.



here is my test code-
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The user you connect with does not have permission to create databases. Speak to your SQL Server admin.
 
Praveen Kumarji
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...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.
 
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
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic