• 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

Creating New SQL DB

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am fairly new at the world of JDBC and SQL. While doing some reading, I have noticed that it seems one must create an SQL database outside of JAVA and then use JDBC to access and manipulate the DB. I was wondering if there was a way, that if SQL was running as a service, there is a way in JAVA to create the DB? Maybe I just overlooked something??
Thanks for any help.

------------------
Happy Coding,
Gregg Bolinger
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can create your table(s) from within java. Check out the CREATE TABLE SQL command of the Statement Interface.

Bosun
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I can create my tables, but can I actually create the DB itself. The way you access the DB is by the name of the DB. What if you want the user to specify a DB name and create a new one.

------------------
Happy Coding,
Gregg Bolinger
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Gregg,
I believe that there exist DB frontends working with JDBC. they need to have the ability to create databases?!
maybe that depends on the db, as well. PostgreSQL has a shellscript createdb to be used outside of the postgres and thus outside of any db environment. but mysql hasn't such a script, I think. what I want to say is: maybe you can create dbs while you're already connected to one. that would solve the problem, wouldn't it?
chantal
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried creating while connected to one, then switched databases. The only problem with that is the fact that there will have to be a default DB on the system created outside of my program. But I can probably figure out a work around. I think MySQL creates a couple of databases on install, so I will probably just connect to one of those by default.
Thanks

------------------
Happy Coding,
Gregg Bolinger
reply
    Bookmark Topic Watch Topic
  • New Topic