Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we create databases from the code ?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I am wondering that if we can create a database (please note, not tables) from Java code.
I don't have any problems with JDBC programming, like insert, create tables .....
but I want to know if we can create databases from the code.
if yes, please tell me how.
thanks alot.
[ December 12, 2004: Message edited by: John Todd ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
No, you can't create a database through JDBC. The main reason is that JDBC requires you to first get a connection to the database. If the database doesn't yet exist, this is a circular problem.

If you really need to use java, you could have a java program call a command line file to create the database. This is operating system specific though.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my problem is :
I have mySQL 4.0 and I don't know how to change the encoding to utf-8
I was thinking about something like :
dbc:mysql://localhost/<database>?useUnicode=true&characterEncoding=utf-8
I have read the docs, trying JavaRanch's open source forum, but no result.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your problem might stem from the version of MySQL you are using. As I remember (you'll have to look this up though to check) versions 4.0 and below only support single-byte characters sets, it only from version 4.1 that MySQL's character encoding and set support dramatically improved. That being said, I always understood that you could store UTF-8 encoded strings in MySQL OK if you handled the encoding issues in your applciation. The only side effect of doing this was that MySQL would possibly sort the data incorrectly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic