Showing posts with label quot1quot. Show all posts
Showing posts with label quot1quot. Show all posts

Monday, February 20, 2012

JDBC getBoolean/setBoolean

Hello
When I call stmt.setBoolean(columnIndex, true); The value of "1" in inserted to column.
However when I call rs.getBoolean(column) I get "false". If manually set column value to "true", the returned value of rs.getBoolean will be true.
Thx in advance...Ilja,
We have just shipped a QFE to fix this mess, you can get this by contacting product support directly with the information you have posted.

You can verify that the behavior is what you expect by using our latest community tech preview drop which contains this fix:

http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en

Thanks,
Angel|||Hi thx for fast reply.
I think I found reason. Column type must be set to "BIT" in order of using booleans on programming side.
Anyway thx.|||

Using BIT certainly helps since this is the type that maps better to the java boolean type. Unfortunatelly for us the JDBC spec is very clear on the allowed conversions for JDBC drivers.

In the case of getboolean we need to support all of the numeric types and do data dependent conversion (conversions that require that the type contain values that can be converted into boolean) for all character based Sql Server types. Before the QFE I mention above we did not.

Glad to hear this worked out for you, good luck

Angel

jdbc driver getTables(String , String ,Sring ,String[] )can't get tables whose catalog is pure

i have a database named "1", then i want to get the tables which type is "TABLE" under this catalog but it can't be done.
Check the kode:
conn.setCatalog("\"1\"");
DatabaseMetaData meta = conn.getMetaData();
ResultSet tables = meta.getTables("\"1\"", "dbo","ttt" , new String [] {"TABLE"});
if i change the last sentence to :
ResultSet tables = meta.getTables("1", "dbo","ttt" , new String [] {"TABLE"}), it still can't be done.
it work when "ResultSet tables = meta.getTables(null, "dbo","ttt" , new String [] {"TABLE"})

I tested this with the SQL Server 2005 JDBC driver and it worked fine.

I created a database named ["1"].

Which SQL Server JDBC driver are you using?

Also try bracketizing the database name like so, this will probably make it work:

ResultSet tables = meta.getTables("[\"1\"]", "dbo","ttt" , new String [] {"TABLE"});

Matt

|||k, i am working under sqlserver 2000 , i change the kode as u do, but it still can't work fine.

steps:
create database through sql : "create database 1".
change the kode to :
ResultSet tables = meta.getTables("[\"1\"]", null,null, new String [] {"TABLE"});
but it still can't work.no table returned.
Have u any idear?

|||i also tried this:
conn.getCatalog() returns "1";
but meta.getCatalogs returns 1;
is it a bug?|||

If you created the database named 1, then use 1 and not "1", so:

ResultSet tables = meta.getTables("[1]", null,null, new String [] {"TABLE"});

Also, if you have SQL Server Profiler you can see what it sent to the SQL Server.

With the SQL 2005 driver I see:

exec sp_tables @.table_qualifier = '"1"', @.table_owner = 'dbo', @.table_name = null , @.table_type = '''TABLE'''

This might help you figure out what the SQL 2000 driver is doing wrong.

I have the SQL 2000 driver setup on my machine I will give it a quick test.

|||

Yes I tested with SQL 2000 JDBC driver and this failed, so it is a bug.

Works fine with SQL 2005 JDBC driver.

I reported this bug to the JDBC PM.

|||3X a lot.