File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating New SQL DB

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bosun Bello
Ranch Hand
Posts: 1510
  • 0
  • Mark post as helpful
  • send pies
  • 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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • 0
  • Mark post as helpful
  • send pies
  • 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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic