LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-03-2011, 03:12 PM   #1
nbcohen
Member
 
Registered: Mar 2003
Location: Northern Virginia
Distribution: RH Enterprise, Fedora
Posts: 96

Rep: Reputation: 17
MySQL - Foreign key failure - but the problem is with Eclipse, I think...


I have created a database with 2 tables (actually 13 tables, but only 2 are involved with this..) One table contains a foreign key reference to the second table.

When I originally created the tables, I had a typo in the foreign key line. So instead of:

CONSTRAINT `dev_id` FOREIGN KEY (`dev_type`) REFERENCES `dev_type` (`id`)

I had

CONSTRAINT `dev_id` FOREIGN KEY (`dev_type`) REFERENCES `rrd_dev_type` (`id`)

So when I tried to insert a record into the first table, I got an error like:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails ("vrsn_rrd"."rrd_info", CONSTRAINT "dev_id" FOREIGN KEY ("dev_type") REFERENCES "rrd_dev_type" ("id"))


So I fixed the typo, dropped the database, recreated the database and now from the command line, I can insert records. HOWEVER, I am working with a java program built with Eclipse to read my input and load this table, and when the program runs, I get the same foreign key error. I have deleted the program war file, deleted the project from Eclipse and recreated it, deleted the database again and rebuilt it, and I can't get the program to load my data.

I am completely inexperienced with Eclipse - I'm assuming it has cached something somewhere, but I can't find it. The fact that I can load a record from the mysql command line tells me the database is now ok.

Can someone give me a hint as to how to get rid of this problem? I am building the code using Eclipse and the Vaadin development environment.

Thanks very much,

nbc
 
Old 05-04-2011, 06:43 AM   #2
nbcohen
Member
 
Registered: Mar 2003
Location: Northern Virginia
Distribution: RH Enterprise, Fedora
Posts: 96

Original Poster
Rep: Reputation: 17
Problem solved...

It was a very long Monday... My apologies. There was a typo in my config file, and I was actually attempting to access the database on a test machine which didn't get the typo fixed instead of the box where I did update the database...
So the problem was simply the database itself. Sorry about that...

nbc
 
Old 05-04-2011, 08:00 AM   #3
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Thank you for the follow up posting. I read your initial post yesterday and really didn't have a clue as to what to suggest. In hind sight, the problem and solution both make perfect sense. I ran into a similar situation a while back. I am using FreeTDS to provide an ODBC driver for a MS-SQL database. When you establish a connection in your application, you reference the tag in the configuration file that is stored in /etc/odbc.ini. In the odbc.ini you make reference to the SQL host and the database of interest. We have multiple database servers that are supposed to mirror each other, more or less, with names that end in 01 and 02 and if you don't point to the right one then as the saying goes "garbage in garbage out".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] What are the key stroke combinations for foreign language accents in Office? Flackbait Linux - Newbie 2 04-13-2010 11:55 AM
sql foreign key constraint fails kpachopoulos Programming 2 02-17-2009 06:49 PM
Mysql foreign key doesn't allow update mohtasham1983 Programming 3 07-25-2008 10:56 PM
MySQL Primairy Key problem agallant Programming 6 06-27-2004 11:12 PM
Mysql Foreign Key munna_502 Linux - Software 0 06-12-2004 04:31 PM


All times are GMT -5. The time now is 01:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration