aspose file tools*
The moose likes JDBC and the fly likes Usage of Reserved words for Database Table fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Usage of Reserved words for Database Table fields " Watch "Usage of Reserved words for Database Table fields " New topic
Author

Usage of Reserved words for Database Table fields

Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
I have one more problem...
Im doing a Database Migration from HSQL to DERBy..

Some of the tables in my Source Database(HSQL) have reserved words like "USER", "CLOSE", "OPEN"...etc

When I migrate the database to DERBY which is my destination DB Im getting trouble with these reserved words... the table which have these reserved words raises exception..and the table is never created..

Any solution to check for the fields which are reserved words ?

Please let me know...

Thanks,
Sudheer.

[ August 01, 2006: Message edited by: Sudheer Yeddu ]
[ August 01, 2006: Message edited by: Sudheer Yeddu ]

A Moment's insight is sometimes worth a Life's experience.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Database migration is nontrivial, especially with create table statements and stored procedures. You could check online documentation for a list of reserved words. As far as converting the data, if you have a large enough set of data you might consider writing a tool that reads the exported SQL data, and does the conversion for you, else you have to do it by hand.


My Blog: Down Home Country Coding with Scott Selikoff
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Originally posted by Sudheer Yeddu:

Some of the tables in my Source Database(HSQL) have reserved words like "USER", "CLOSE", "OPEN"...etc


Some databases allow you to use reserved words (or even mixed-case table names) by quoting the table name. For example:



I don't know enough about the DBs you're using to know if that's helpful.

Usually, if you have to create them with quotes, then you also have to reference them with quotes in your SELECT and INSERT statements.
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
Thanks for the replies...

I also want to know whether we have any way to track the reserved words, so that I can wrap them in quotes to work after locating them..

Thanks,
Sud
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
please go thru my blog if needed, btw I have published in my blog as it may be of any help to folks doing the same...

http://taurivalor.wordpress.com/

Thanks,
Sudheer.
Tauri Valor
Ranch Hand

Joined: Aug 03, 2005
Posts: 166
Finally I could do it this way..

I Put the reserved words in an array and did a check if the field name matches any one of the elements in that array.

Cheers,
Sud.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Usage of Reserved words for Database Table fields
 
Similar Threads
Long time ago,
Is there is any way to connect to Database without JDBC
Words reserved but not used
Database Migration (Migrating only Tables, leaving Views)
The best puzzle(IIM Indore)