File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes jdbc-sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc-sql" Watch "jdbc-sql" New topic
Author

jdbc-sql

ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
just started using jdbc after a long time so am not sure about the table creation syntax in mysql.I think it has something to do with indexing.

any help would be appreciated.
*********************************************
mysql> create table county ( countynumber integer not null auto_increment,
-> countyname varchar(32),
-> state varchar(32),
-> primary key(countynumber));
Query OK, 0 rows affected (0.38 sec)

mysql> create table voterregistration(
-> ssn integer not null,
-> firstname varchar(32) not null,
-> lastname varchar(32) not null,
-> countynumber integer not null,
-> primary key(ssn),
-> foreign key(countynumber) references county);
ERROR 1005 (HY000): Can't create table '.\jspexample\voterregistration.frm' (err
no: 150)
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
Not to sound mean or demeaning, but try the forums at www.mysql.org
ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
my mistake:-(

the following works:

*****************************************
ALTER TABLE county ADD INDEX(countynumber);

> create table voterregistration(
-> ssn integer not null,
-> firstname varchar(32) not null,
-> lastname varchar(32) not null,
-> countynumber integer not null,
-> primary key(ssn),
-> foreign key(countynumber) references county(countynumber))
-> ENGINE=InnoDB;
Query OK, 0 rows affected (0.11 sec)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc-sql