 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
z0man Guest
|
Posted: Sun Jan 29, 2006 6:52 pm Post subject: MySQL and Java : Column not found |
|
|
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
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Sun Jan 29, 2006 7:17 pm Post subject: Re: MySQL and Java : Column not found |
|
|
Sorry I meant to say:
It says "the column not found".
z0man wrote:
| Quote: | 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
|
|
|
| Back to top |
|
 |
IchBin Guest
|
Posted: Sun Jan 29, 2006 8:46 pm Post subject: Re: MySQL and Java : Column not found |
|
|
z0man wrote:
| Quote: | Sorry I meant to say:
It says "the column not found".
z0man wrote:
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
What does you database table definition look like? Just in case.. |
--
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-)
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Sun Jan 29, 2006 11:02 pm Post subject: Re: MySQL and Java : Column not found |
|
|
IchBin wrote:
| Quote: | 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
--
-- 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
=======================
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Mon Jan 30, 2006 5:15 pm Post subject: Re: MySQL and Java : Column not found |
|
|
IchBin wrote:
| Quote: | z0man
What does you database table definition look like? Just in case..
Here is a better view of the table |
+---------+--------------+------+-----+---------+----------------+
| Quote: | 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;
+----------------+-------------------+
| Quote: | heading | article |
+----------------+-------------------+
Test Heading 3 | My first document |
+----------------+-------------------+ |
I compiled it Java and saddly no it didn't work
z0man
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Mon Jan 30, 2006 5:51 pm Post subject: Re: MySQL and Java : Column not found |
|
|
z0man wrote:
| Quote: | 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
|
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
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Mon Jan 30, 2006 6:23 pm Post subject: Re: MySQL and Java : Column not found |
|
|
z0man wrote:
| Quote: | 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
|
|
| Back to top |
|
 |
Bill Karwin Guest
|
Posted: Mon Jan 30, 2006 6:23 pm Post subject: Re: MySQL and Java : Column not found |
|
|
"z0man" <z0manifest (AT) kc (DOT) rr.com> wrote
| Quote: | 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.
|
|
| Back to top |
|
 |
z0man Guest
|
Posted: Mon Jan 30, 2006 8:12 pm Post subject: Re: MySQL and Java : Column not found |
|
|
Bill Karwin wrote:
| Quote: | "z0man" <z0manifest (AT) kc (DOT) rr.com> wrote in message
news:VmsDf.85756$Dk.19439 (AT) tornado (DOT) rdc-kc.rr.com...
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.
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
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|