Welcome to dbForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

JDBC driver has issues with VARCHAR(24)

 
   Database Forums (Home) -> JDBC Driver RSS
Next:  Can't repopulate Catalog: change tracking not wor..  
Author Message
Rick Spickelmier

External


Since: Feb 14, 2008
Posts: 1



(Msg. 1) Posted: Thu Feb 14, 2008 11:37 am
Post subject: JDBC driver has issues with VARCHAR(24)
Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)

All of my VARCHAR(24) columns are reported as size 7 from
java.sql.DatabaseMetaData::getColumns. All other sizes from 1 to 49 report
the correct COLUMN_SIZE.

Any ideas?

The following program shows the problem (using 1.2.2828.100 against SQL
Server 2005):

import java.sql.* ;

class JDBCQuery
{
public static void main( String args[] )
{
try
{
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" ) ;
Connection conn =
DriverManager.getConnection("jdbc:sqlserver://colo3:1433;databaseName=test",
"test", "test");

Statement stmt = conn.createStatement();
String ctable = "CREATE TABLE TEST (f1 varchar(1)";
for (int i = 2; i < 50; i++)
{
ctable = ctable + ",f" + i + " varchar(" + i + ")";
}
ctable = ctable + ")";
System.out.println(ctable);

stmt.execute(ctable);

java.sql.DatabaseMetaData meta = conn.getMetaData();
ResultSet set = meta.getColumns(conn.getCatalog(), null, "TEST", null);
while (set.next())
{
System.out.println(set.getString("COLUMN_NAME") + ", " +
set.getString("TYPE_NAME") + ", " + set.getString("COLUMN_SIZE"));
}
stmt.execute("DROP TABLE TEST");
}
catch( SQLException se )
{
System.out.println( "SQL Exception: " + se.getMessage()) ;
}
catch( Exception e )
{
System.out.println( e ) ;
}
}
}

C:\temp>java -cp ".;sqljdbc.jar" JDBCQuery
CREATE TABLE TEST (f1 varchar(1),f2 varchar(2),f3 varchar(3),f4
varchar(4),f5 varchar(5),f6 varchar(6),f7 varchar(7),f8
varchar(Cool,f9 varchar(9),f10 varchar(10),f11 varchar(11),f12 varchar(12),f13
varchar(13),f14 varchar(14),f15 varchar(15)
,f16 varchar(16),f17 varchar(17),f18 varchar(1Cool,f19 varchar(19),f20
varchar(20),f21 varchar(21),f22 varchar(22),f23 var
char(23),f24 varchar(24),f25 varchar(25),f26 varchar(26),f27 varchar(27),f28
varchar(2Cool,f29 varchar(29),f30 varchar(30)
,f31 varchar(31),f32 varchar(32),f33 varchar(33),f34 varchar(34),f35
varchar(35),f36 varchar(36),f37 varchar(37),f38 var
char(3Cool,f39 varchar(39),f40 varchar(40),f41 varchar(41),f42 varchar(42),f43
varchar(43),f44 varchar(44),f45 varchar(45)
,f46 varchar(46),f47 varchar(47),f48 varchar(4Cool,f49 varchar(49))
f1, varchar, 1
f2, varchar, 2
f3, varchar, 3
f4, varchar, 4
f5, varchar, 5
f6, varchar, 6
f7, varchar, 7
f8, varchar, 8
f9, varchar, 9
f10, varchar, 10
f11, varchar, 11
f12, varchar, 12
f13, varchar, 13
f14, varchar, 14
f15, varchar, 15
f16, varchar, 16
f17, varchar, 17
f18, varchar, 18
f19, varchar, 19
f20, varchar, 20
f21, varchar, 21
f22, varchar, 22
f23, varchar, 23
f24, varchar, 7
f25, varchar, 25
f26, varchar, 26
f27, varchar, 27
f28, varchar, 28
f29, varchar, 29
f30, varchar, 30
f31, varchar, 31
f32, varchar, 32
f33, varchar, 33
f34, varchar, 34
f35, varchar, 35
f36, varchar, 36
f37, varchar, 37
f38, varchar, 38
f39, varchar, 39
f40, varchar, 40
f41, varchar, 41
f42, varchar, 42
f43, varchar, 43
f44, varchar, 44
f45, varchar, 45
f46, varchar, 46
f47, varchar, 47
f48, varchar, 48
f49, varchar, 49

 >> Stay informed about: JDBC driver has issues with VARCHAR(24) 
Back to top
Login to vote
Joe Weinstein

External


Since: Oct 24, 2003
Posts: 512



(Msg. 2) Posted: Thu Feb 14, 2008 1:15 pm
Post subject: Re: JDBC driver has issues with VARCHAR(24) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Rick Spickelmier wrote:

> All of my VARCHAR(24) columns are reported as size 7 from
> java.sql.DatabaseMetaData::getColumns. All other sizes from 1 to 49 report
> the correct COLUMN_SIZE.
>
> Any ideas?

Hi. This is a bug in the driver. The sp_columns stored procedure
being called by the driver for the actual data is correct, and
returns the right values, but the driver is improperly taking
all that data and 'filtering' it via PrecisionFilter, which interprets
17 and 53 as ODBC values, and these are converted to 7 and 15
respectively.

Joe Weinstein at BEA Systems

 >> Stay informed about: JDBC driver has issues with VARCHAR(24) 
Back to top
Login to vote
Rick Spickelmier

External


Since: Feb 14, 2008
Posts: 1



(Msg. 3) Posted: Thu Feb 14, 2008 2:39 pm
Post subject: Re: JDBC driver has issues with VARCHAR(24) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks! Any ideas if this is a 'known for a while, but not fixed' issue?

As a test I tried out jtds and it worked for my example.

Rick

"Joe Weinstein" wrote:

>
>
> Rick Spickelmier wrote:
>
> > All of my VARCHAR(24) columns are reported as size 7 from
> > java.sql.DatabaseMetaData::getColumns. All other sizes from 1 to 49 report
> > the correct COLUMN_SIZE.
> >
> > Any ideas?
>
> Hi. This is a bug in the driver. The sp_columns stored procedure
> being called by the driver for the actual data is correct, and
> returns the right values, but the driver is improperly taking
> all that data and 'filtering' it via PrecisionFilter, which interprets
> 17 and 53 as ODBC values, and these are converted to 7 and 15
> respectively.
>
> Joe Weinstein at BEA Systems
>
>
 >> Stay informed about: JDBC driver has issues with VARCHAR(24) 
Back to top
Login to vote
Joe Weinstein

External


Since: Oct 24, 2003
Posts: 512



(Msg. 4) Posted: Thu Feb 14, 2008 3:04 pm
Post subject: Re: JDBC driver has issues with VARCHAR(24) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Rick Spickelmier wrote:

> Thanks! Any ideas if this is a 'known for a while, but not fixed' issue?
>
> As a test I tried out jtds and it worked for my example.
>
> Rick

I don't know what MS knows... I'd guess they don't know
about it except through your case in this post.
Joe

>
> "Joe Weinstein" wrote:
>
>
>>
>>Rick Spickelmier wrote:
>>
>>
>>>All of my VARCHAR(24) columns are reported as size 7 from
>>>java.sql.DatabaseMetaData::getColumns. All other sizes from 1 to 49 report
>>>the correct COLUMN_SIZE.
>>>
>>>Any ideas?
>>
>>Hi. This is a bug in the driver. The sp_columns stored procedure
>>being called by the driver for the actual data is correct, and
>>returns the right values, but the driver is improperly taking
>>all that data and 'filtering' it via PrecisionFilter, which interprets
>>17 and 53 as ODBC values, and these are converted to 7 and 15
>>respectively.
>>
>>Joe Weinstein at BEA Systems
>>
>>
 >> Stay informed about: JDBC driver has issues with VARCHAR(24) 
Back to top
Login to vote
David Olix

External


Since: Feb 17, 2006
Posts: 19



(Msg. 5) Posted: Tue Feb 19, 2008 9:53 pm
Post subject: Re: JDBC driver has issues with VARCHAR(24) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

And we know about it now... Smile

Joe is spot on, of course. I haven't the slightest idea why the value is
filtered independent of the data type...

We will certainly address this defect in a future release. If this issue
is blocking for you, I encourage you to open a case with MIcrosoft Customer
Support Services.

Thanks again for raising this to our attention!

Regards,
--David Olix [MSFT]
 >> Stay informed about: JDBC driver has issues with VARCHAR(24) 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> JDBC Driver All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]