 |
|
 |
|
Next: Indexing (and searching for) percentages
|
| Author |
Message |
External

Since: Apr 28, 2008 Posts: 3
|
(Msg. 1) Posted: Mon Apr 28, 2008 1:06 pm
Post subject: Getting zero terminated string through (both jTDS & MS) jdbc driver Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)
|
|
|
Hi,
I am having a curious problem that I verified now with both the
MS JDBC Driver 1.2 and jTDS (both show same strange behaviour).
The Strangeness is that it looks like I am receiving 0 terminated
strings through the jTDS/MS JDBC driver, except the driver
does not realize this. This means, a variable length column, eg.:
varchar(15) is always 15 characters in length and the correct length
is zero terminated.
I am working with a varchar column and when I use the getString()
Method of the ResultSet Object I receive Strings with binary zeros.
I also verified this behaviour with getCharacterStream() function.
The problem shows as follows:
String in Table Received String (In Order of Query)
---------------------------------------------------------
dirk dirk^^^^^^^^^^^
db db^k^^^^^^^^^^^
hello hello^^^^^^^^^^
x x^llo^^^^^^^^^^
---------------------------------------------------------
'^' => I use this character to escape binary zero
To me this looks like a fixed length buffer is used and
the getString() method always returns the full size, even
though the datatype is varchar(15). I can verify this problem
only in connection with Microsoft SQL Server 2000. I have
tested with other Microsoft/Sybase Servers and can not
re-create this behaviour(?).
Does any one know any setting or config I could try?
Is this a known bug or is there a workaround? Please
tell me if you need config infos I'll see if I can get it for
posting here...
Thanks a lot for any helpful hints,
Cheers Dirk >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
External

Since: Oct 24, 2003 Posts: 232
|
(Msg. 2) Posted: Mon Apr 28, 2008 4:22 pm
Post subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi. Please write a tiny standalone program that demonstrates the problem, eg:
import java.sql.*;
import java.util.*;
public class foo
{
public static void main(String argv[])
throws Exception
{
Connection c = null;
try
{
Properties props = new Properties();
Driver d = new com.microsoft.sqlserver.jdbc.SQLServerDriver();
props.put("user", "sa");
props.put("password", "secret");
c = d.connect("jdbc:sqlserver://localhost:1433", props );
System.out.println("Driver version is " + c.getMetaData().getDriverVersion() );
System.out.println("DBMS version is " + c.getMetaData().getDatabaseProductVersion() )
;
Statement s = c.createStatement();
s.executeUpdate("CREATE TABLE #foo(bar varchar(25))");
s.executeUpdate("insert #foo values('a')");
s.executeUpdate("insert #foo values('bbbbbbbb')");
s.executeUpdate("insert #foo values('ccccccccccccccccc')");
s.executeUpdate("insert #foo values('dddddddddddddddddddd')");
ResultSet rs = s.executeQuery("select * from #foo");
while (rs.next()) System.out.println( ... whatever you find odd... );
}
catch(Exception exception1)
{
exception1.printStackTrace();
}
finally
{
if (c != null) try {c.close();} catch (Exception ignore){}
}
}
}
dirk_bahle DeleteThis @gmx.de wrote:
> Hi,
>
> I am having a curious problem that I verified now with both the
> MS JDBC Driver 1.2 and jTDS (both show same strange behaviour).
> The Strangeness is that it looks like I am receiving 0 terminated
> strings through the jTDS/MS JDBC driver, except the driver
> does not realize this. This means, a variable length column, eg.:
> varchar(15) is always 15 characters in length and the correct length
> is zero terminated.
>
> I am working with a varchar column and when I use the getString()
> Method of the ResultSet Object I receive Strings with binary zeros.
> I also verified this behaviour with getCharacterStream() function.
>
> The problem shows as follows:
>
> String in Table Received String (In Order of Query)
> ---------------------------------------------------------
> dirk dirk^^^^^^^^^^^
> db db^k^^^^^^^^^^^
> hello hello^^^^^^^^^^
> x x^llo^^^^^^^^^^
> ---------------------------------------------------------
>
> '^' => I use this character to escape binary zero
>
> To me this looks like a fixed length buffer is used and
> the getString() method always returns the full size, even
> though the datatype is varchar(15). I can verify this problem
> only in connection with Microsoft SQL Server 2000. I have
> tested with other Microsoft/Sybase Servers and can not
> re-create this behaviour(?).
>
> Does any one know any setting or config I could try?
> Is this a known bug or is there a workaround? Please
> tell me if you need config infos I'll see if I can get it for
> posting here...
>
> Thanks a lot for any helpful hints,
> Cheers Dirk >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
External

Since: Apr 28, 2008 Posts: 3
|
(Msg. 3) Posted: Tue Apr 29, 2008 11:01 am
Post subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi Joe,
thanks for your suggestion. I wrote a simplified program and verified
the problem. That was I was able
to see that the database actually stored the '\0' values in a varchar
field. I used a port sniffer to make
sure the database actually sends the '\0' 's in the varchar field.
I was not able to recognize this earlier because the Microsoft Visual
Studio does not show additional
binary zeros, if they occur in a varchar field. Now I wonder if this
is a bug in the Studio or if there is a
setting/option to "get what you stored" in a varchar field(?).
Anyways, as far as I am concerned my case is resolved, thanks again
for you suggestion.
Cheers Dirk >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
External

Since: Nov 21, 2006 Posts: 24
|
(Msg. 4) Posted: Tue Apr 29, 2008 8:19 pm
Post subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc driver [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Dirk,
In your post, you said that you only see this with SQL Server 2000. What service pack of SQL Server are you running?
Evan
--------------------
>From: "dirk_bahle@gmx.de"
>Newsgroups: microsoft.public.sqlserver.jdbcdriver
>Subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc
> driver
>Date: Tue, 29 Apr 2008 11:01:15 -0700 (PDT)
>Organization: http://groups.google.com
>Lines: 18
>Message-ID:
>References:
>
>NNTP-Posting-Host: 80.135.120.80
>Mime-Version: 1.0
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 7bit
>X-Trace: posting.google.com 1209492075 21495 127.0.0.1 (29 Apr 2008 18:01:15 GMT)
>X-Complaints-To: groups-abuse.TakeThisOut@google.com
>NNTP-Posting-Date: Tue, 29 Apr 2008 18:01:15 +0000 (UTC)
>Complaints-To: groups-abuse.TakeThisOut@google.com
>Injection-Info: 34g2000hsf.googlegroups.com; posting-host=80.135.120.80;
> posting-account=ZAptOQoAAAAGJ74r-gMGDSAqa8pjvAKm
>User-Agent: G2/1.0
>X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.8.1.1)
> Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe)
>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!TK2MSFTFEEDS01.phx.gbl!msrtrans!msrn-in!
newshub.sdsu.edu!postnews.google.com!34g2000hsf.googlegroups.com!not-for-mail
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.jdbcdriver:503
>X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
>
>Hi Joe,
>
>thanks for your suggestion. I wrote a simplified program and verified
>the problem. That was I was able
>to see that the database actually stored the '\0' values in a varchar
>field. I used a port sniffer to make
>sure the database actually sends the '\0' 's in the varchar field.
>
>I was not able to recognize this earlier because the Microsoft Visual
>Studio does not show additional
>binary zeros, if they occur in a varchar field. Now I wonder if this
>is a bug in the Studio or if there is a
>setting/option to "get what you stored" in a varchar field(?).
>
>Anyways, as far as I am concerned my case is resolved, thanks again
>for you suggestion.
>
>Cheers Dirk
>
Evan T. Basalik
This posting is provided “AS IS” with no warranties, and confers no rights. >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
External

Since: Apr 28, 2008 Posts: 3
|
(Msg. 5) Posted: Mon May 05, 2008 3:52 am
Post subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi Evan,
my problem case was running on SP2, Build 3200. We have looked deeper
into it and it looks like
the binary zeros '\0' were introduced on a different Server (other
brand than Microsoft) and then got
transmitted to MS SQL Server 2000. This went all unnoticed, because
the Visual Studio did not show
any '\0' in the varchar output.
In this way the JDBC driver actually helped us finding a (possible)
problem in the processing chain. I am
wondering if there is a regression style test in which one could run
an OLE DB Provider and a JDBC Driver
'against' each other to see, if and where, they return different
results. A summary from such a test would be
interesting for anyone trying to migrate from C# to Java or vice
versa. Is there such a thing (as a complete
comparison between the actual JDBC and OLE DB Driver)?
Cheers Dirk >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
External

Since: Nov 21, 2006 Posts: 24
|
(Msg. 6) Posted: Tue May 20, 2008 1:46 am
Post subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc driver [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Dirk,
Unfortunately, this kind of tool does not currently exist. We have talked about it internally a couple of times, but it has never come to fruition. If you end up
writing something along these lines, please let me know!
Evan
--------------------
>From: "dirk_bahle@gmx.de"
>Newsgroups: microsoft.public.sqlserver.jdbcdriver
>Subject: Re: Getting zero terminated string through (both jTDS & MS) jdbc
> driver
>Date: Mon, 5 May 2008 03:52:43 -0700 (PDT)
>Organization: http://groups.google.com
>Lines: 21
>Message-ID:
>References:
>
>
>NNTP-Posting-Host: 193.16.163.243
>Mime-Version: 1.0
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 7bit
>X-Trace: posting.google.com 1209984763 10031 127.0.0.1 (5 May 2008 10:52:43 GMT)
>X-Complaints-To: groups-abuse RemoveThis @google.com
>NNTP-Posting-Date: Mon, 5 May 2008 10:52:43 +0000 (UTC)
>Complaints-To: groups-abuse RemoveThis @google.com
>Injection-Info: a70g2000hsh.googlegroups.com; posting-host=193.16.163.243;
> posting-account=ZAptOQoAAAAGJ74r-gMGDSAqa8pjvAKm
>User-Agent: G2/1.0
>X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14)
> Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)
>X-HTTP-Via: 1.0 cache.netrtl.com:8080 (squid/2.5.STABLE5)
>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS01.phx.gbl!msrtrans!msrn-in!newshub.sdsu.edu!postnews.google.com!
a70g2000hsh.googlegroups.com!not-for-mail
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.sqlserver.jdbcdriver:508
>X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
>
>Hi Evan,
>
>my problem case was running on SP2, Build 3200. We have looked deeper
>into it and it looks like
>the binary zeros '\0' were introduced on a different Server (other
>brand than Microsoft) and then got
>transmitted to MS SQL Server 2000. This went all unnoticed, because
>the Visual Studio did not show
>any '\0' in the varchar output.
>
>In this way the JDBC driver actually helped us finding a (possible)
>problem in the processing chain. I am
>wondering if there is a regression style test in which one could run
>an OLE DB Provider and a JDBC Driver
>'against' each other to see, if and where, they return different
>results. A summary from such a test would be
>interesting for anyone trying to migrate from C# to Java or vice
>versa. Is there such a thing (as a complete
>comparison between the actual JDBC and OLE DB Driver)?
>
>Cheers Dirk
>
Evan T. Basalik
This posting is provided “AS IS” with no warranties, and confers no rights. >> Stay informed about: Getting zero terminated string through (both jTDS & MS) jd.. |
|
| Back to top |
|
 |  |
| Related Topics: | JTDS Driver Connect Problem - one works, one doesn't - I'm having a problem connecting to SQL-Server 2005 using the JTDS 1.22 JDBC driver. This occurs for only one of two SQL-Server 2005 instances I have. The specifics are: I have two machines, each loaded with SQL-Server 2005, one a 64-bit Server, an...
How to genericaly search the entire db for any text string.. - How to genericaly search the entire db for any text string in any stored procedure, function, table definition, agent job, etc. Any one command or anyone have a stored proc that does this wide search?
MDX and JDBC Driver - Hi all, Anybody know if it possible to connect to an as2000 database and run mdx queries using the microsoft jdbc drivers? thanks, Peter
java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]U.. - Folks, I was getting this exception occasionally and tracked in down to the application server C drive being full. Looks like the drivers are writing to logs (event ?) on this drive. Freeing up space removed the problem. Hope this helps someone. ..
JDBC driver doesn't close socket event after connection.cl.. - Hi I have a Java application (on Red Hat Enterprise) that <font color=purple> ; 1) connects every 10 seconds to an MS/SQL database</font> <font color=purple> ; 2) attempts to get the metadata for a specific table</fo... |
|
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
|
|
|
|
 |
|
|