Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pb with the JDBC driver for Msql - getString method

0 views
Skip to first unread message

Fabrice Albrecht

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

I'm using java to connect to my Msql database.

Has anybody experimented the getString method of the JDBC "imaginary"
driver for msql ?

In the ResultSet implementation, I managed with the getString(int
columnIndex) which gives me the good result, but I can't used neither
the GetString(String ColumnName) nor the findColumn(String ColumnName)
method.

In fact, it acts as if the driver didn't recognize the real names of the
fields of my tables.

error messages are something like :
[ Exception (hint : -1) java.sql.SQLException: -1
java.sql.SQLException: -1
at imaginary.sql.iMsqlMetaResult.getColumnName(iMsqlMetaResult.java:155)
at imaginary.sql.iMsqlResultSet.findColumn(iMsqlResultSet.java:803) ]

Can anybody help me ?

--
*************************************************************
Fabrice Albrecht
INRIA - Projet SOR - BP 105 - 78153 Le Chesnay Cedex - France
e-mail : Fabrice....@inria.fr - Tel : (1) 39.63.57.55
*************************************************************

Jerry Ablan

unread,
Jul 1, 1996, 3:00:00 AM7/1/96
to

Fabrice Albrecht wrote:

> In the ResultSet implementation, I managed with the getString(int
> columnIndex) which gives me the good result, but I can't used neither
> the GetString(String ColumnName) nor the findColumn(String ColumnName)
> method.

The current version of mSQL-JDBC does not support the gets by column name. Only by number.

-- Jerry

---------------------------------------------------
Ablan \'a-blin\ n: See Geek
---------------------------------------------------
WEB: http://www.mcs.net/~munster/
EMAIL: mun...@mcs.net
---------------------------------------------------
"Star-bellied sneetches rule!!" -- Beavis
---------------------------------------------------

Ryan L McFall

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

Fabrice Albrecht (Fabrice....@inria.fr) wrote:
: I'm using java to connect to my Msql database.

: Has anybody experimented the getString method of the JDBC "imaginary"
: driver for msql ?

: In the ResultSet implementation, I managed with the getString(int


: columnIndex) which gives me the good result, but I can't used neither
: the GetString(String ColumnName) nor the findColumn(String ColumnName)
: method.

: In fact, it acts as if the driver didn't recognize the real names of the
: fields of my tables.

: error messages are something like :
: [ Exception (hint : -1) java.sql.SQLException: -1
: java.sql.SQLException: -1
: at imaginary.sql.iMsqlMetaResult.getColumnName(iMsqlMetaResult.java:155)
: at imaginary.sql.iMsqlResultSet.findColumn(iMsqlResultSet.java:803) ]

If you examine the code for the findColumn method, you'll find that it has
a bug in it. I fixed it and everything seems to work fine.

Unfortunately, I didn't document what I changed. However, I believe it is
in the findColumn (String name) method of the iMsqlResultSet class.

The line:
column_map.put (m.getColumnName(i-1), new Integer(i+1))
should read
column_map.put (m.getColumnName(i), new Integer(i+1))

If you make this change and recomple the ResultSet class, you should be
fine.

Let me know if this doesn't work.

Ryan
--
/**************************************************************
* Ryan McFall *
* Dept. of Computer Science *
* Michigan State University *
* mcfa...@cps.msu.edu *
* *
* My statments do not reflect the opinions of MSU, *
* Heck, they probably don't even make sense! *
*************************************************************/

Ryan L McFall

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

Jerry Ablan (mun...@mcs.net) wrote:
: Fabrice Albrecht wrote:
:
: > In the ResultSet implementation, I managed with the getString(int
: > columnIndex) which gives me the good result, but I can't used neither
: > the GetString(String ColumnName) nor the findColumn(String ColumnName)
: > method.

: The current version of mSQL-JDBC does not support the gets by column name.
: Only by number.


Umm, I don't think so. Better check to make sure that you've really got the
current version. I've got 0.73, and after making a small change to fix a
bug in the code (described in another post), it works fine.

Ryan L McFall

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

Ryan L McFall (mcfa...@cps.msu.edu) wrote:
[text by Fabrice Albrecht deleted]
: If you examine the code for the findColumn method, you'll find that it has

: a bug in it. I fixed it and everything seems to work fine.

: Unfortunately, I didn't document what I changed. However, I believe it is
: in the findColumn (String name) method of the iMsqlResultSet class.

: The line:
: column_map.put (m.getColumnName(i-1), new Integer(i+1))
: should read
: column_map.put (m.getColumnName(i), new Integer(i+1))

: If you make this change and recompile the ResultSet class, you should be
: fine.

My own solution didn't make much sense to me, so I played around a little
more. It appears that the meta-data classes treat the first column in
a result set as column 0, while the ResultSet classes treat it as column
1. This is why the hashtable contains entries for columns 0 to NumColumns-1,
but it must put in associated values 1 to NumColumns.

I'll email this to the imaginary driver author and let him know ...

Ryan L McFall

unread,
Jul 2, 1996, 3:00:00 AM7/2/96
to

Last follow up, for anyone following this thread.

Fabrice Albrecht and I determined there are two ways to fix this
problem:

1) Change line 803 of iMsqlResultSet.java to:
column_map.put (m.getColumnName(i+1), new Integer (i+1))

(Fabrice's solution)

2) Change line 152 of iMsqlMetaResult.java to:
return f[column].FieldName()

Either one of these two should work, as long as you don't do them both!

0 new messages