Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / January 2006

Tip: Looking for answers? Try searching our database.

MySQL and Java : Column not found

Thread view: 
z0man - 29 Jan 2006 18:52 GMT
I have a database called dbuild and a table called news

with sample entries added by the DB_News.java  So I have managed to
communicate to the MySQL database and do stuff.

Here is my new problem when I try and get "article" which is a "TEXT"
data format.  It says the column is there. BUT IT IS!!!

  news_id = getnews_id();
  dbhandler.newSession();
  String sql = "select * from news where id = '"+news_id+"'";
  rs = dbhandler.doQuery(sql);
  headingTextField.setText(rs.getString("heading"));<-- This works
  contentTextArea.setText(rs.getString("article")); <-- This does work
  dbhandler.closeSession();

Any help much apperciated

z0man
z0man - 29 Jan 2006 19:17 GMT
Sorry I meant to say:

It says "the column not found".

> I have a database called dbuild and a table called news
>
[quoted text clipped - 15 lines]
>
> z0man
IchBin - 29 Jan 2006 20:46 GMT
> Sorry I meant to say:
>
[quoted text clipped - 19 lines]
>>
>> z0man
What does you database table definition look like? Just in case..

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

z0man - 29 Jan 2006 23:02 GMT
>>> z0man
> What does you database table definition look like? Just in case..

=======================
START OF MYSQLDUMP:news
=======================
-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
Signature

-- Host: localhost
-- Generation Time: Jan 29, 2006 at 05:00 PM
-- Server version: 4.1.13
-- PHP Version: 5.0.4
--
-- Database: `dbuild`
--

-- --------------------------------------------------------

--
-- Table structure for table `news`
--

DROP TABLE IF EXISTS `news`;
CREATE TABLE IF NOT EXISTS `news` (
  `n_id` mediumint(9) NOT NULL auto_increment,
  `heading` varchar(255) NOT NULL default '',
  `article` text NOT NULL,
  PRIMARY KEY  (`n_id`),
  FULLTEXT KEY `article` (`article`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `news`
--

INSERT INTO `news` VALUES (1, 'My first Article', '');
INSERT INTO `news` VALUES (2, 'My first', 'text goes here');
INSERT INTO `news` VALUES (3, 'heading', 'hi this is my second');
INSERT INTO `news` VALUES (4, 'Test Heading 3', 'My first document');
INSERT INTO `news` VALUES (5, 'test 4', '');
INSERT INTO `news` VALUES (6, 'HI AGAIN', 'My 5th ');

---------

=======================
END OF MYSQLDUMP:news
=======================

z0man - 30 Jan 2006 17:15 GMT
>>> z0man
> What does you database table definition look like? Just in case..

Here is a better view of the table
+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| n_id    | mediumint(9) |      | PRI | NULL    | auto_increment |
| heading | varchar(255) |      |     |         |                |
| article | text         |      | MUL |         |                |
+---------+--------------+------+-----+---------+----------------+

I saw somone trying to enumarate the SELECT instead of using the * for
example,

mysql> select `heading`,`article` from news where n_id = 4;
+----------------+-------------------+
| heading        | article           |
+----------------+-------------------+
| Test Heading 3 | My first document |
+----------------+-------------------+

I compiled it Java and saddly no it didn't work

z0man
z0man - 30 Jan 2006 17:51 GMT
> I have a database called dbuild and a table called news
>
[quoted text clipped - 15 lines]
>
> z0man

I think it could be because the TEXT format does not work with
rs.getString(String colname);  I have tried using rs.getString(int col)
and that dont work either.  Any suggestions?

I decided to post this to mysql.com forum as I really stumped.

z0man
z0man - 30 Jan 2006 18:23 GMT
> I decided to post this to mysql.com forum as I really stumped.
>
> z0man

Here is the link to MySQL if you wish to investigate

http://forums.mysql.com/read.php?39,66978,66978#msg-66978

z0man
Bill Karwin - 30 Jan 2006 18:23 GMT
> I think it could be because the TEXT format does not work with
> rs.getString(String colname);  I have tried using rs.getString(int col)
> and that dont work either.  Any suggestions?

I'm not sure because I haven't done this, but perhaps you should use the
getBlob() method instead of the getString() method?  Or perhaps
getInputStream() or getBytes()?

Regards,
Bill K.
z0man - 30 Jan 2006 20:12 GMT
>> I think it could be because the TEXT format does not work with
>> rs.getString(String colname);  I have tried using rs.getString(int col)
[quoted text clipped - 6 lines]
> Regards,
> Bill K.

Tried the getBlog, the InputStream and getBytes(col).  Then after
finding they all didn't work, it made me aware that I didn't close the
result on the first run!

I figured it out BA!!!

Thanks for that thought though much appreciated :D

Sometimes a Programer's mind needs reseting by taking other peoples
advice and then along the way you figure it out :D

Wooo HOO!

z0man

poncy stupid resultset Didn't close.  I was using a ResultSetTableModel
and it shows it does close the result BA :P

Thanks for your help


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.