MS SQL Server, JDBC, and Unicode?

L

Lew

Arne said:
Can you backtranslate analogu->real world ?

Sure: it wasn't a very good analogy. It's actually not like trying to catch
a black cat in a dark room blindfolded.
 
M

Martin Gregorie

Obviously, one would stuff the SQL Server machine with tuna.

However, in this case, the server is on a virtual machine. Not sure how
to proceed here.
Virtualise the tuna.
 
A

Arved Sandstrom

Tom said:
Tom said:
Has anyone made SQL Server work with unicode in java?

I can't get it not to work.

:)

The following is tested with the MS driver (driver for 2000
against 2000, but I expect 2005 against 2005 to work identical):

public class Unicode {
public static void main(String[] args) throws Exception {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// SQLServer 2000
Connection con =
DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost;DatabaseName=Test",
"sa", "");
Statement stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE unifun (id INTEGER NOT NULL,
data NVARCHAR(50), PRIMARY KEY(id))");
stmt.executeUpdate("INSERT INTO unifun VALUES(1,N'?????? the
wrong way')");
PreparedStatement pstmt = con.prepareStatement("INSERT INTO
unifun VALUES(?,?)");
pstmt.setInt(1, 2);
pstmt.setString(2, "?????? the correct way");
pstmt.executeUpdate();
ResultSet rs = stmt.executeQuery("SELECT id,data FROM unifun");
while(rs.next()) {
System.out.println(rs.getInt(1) + " : " + rs.getString(2));
}
rs.close();
stmt.executeUpdate("DROP TABLE unifun");
stmt.close();
con.close();
}
}

Silly question, but those ?s were unicode characters before you pasted
this into usenet, right?
[ SNIP ]

FWIW, Tom, I saw his original characters OK when I read his post...just
a bunch of unlauts that he'd need when he reads and writes in his
heathen language... :)

AHS

* I'm one to talk - if I read and write in my mother tongue I need äöüõ.
 
L

Lew

Tom said:
Silly question, but those ?s were unicode characters before you pasted
this into usenet, right?
[ SNIP ]

Arved said:
FWIW, Tom, I saw his original characters OK when I read his post...just
a bunch of unlauts [sic] that he'd need when he reads and writes in his
heathen language... :) ....
* I'm one to talk - if I read and write in my mother tongue I need äöüõ.

Even to write in my heathen mother tongue, American English, in which the use
of foreign "loan" words is hardly taboo, if one writes with éclat, casting
one's words into the æther for all to read, hoping to make a difference in the
noösphere, or perhaps just to explain to one's classmate Ramòn how to expand
all the digits of π, one might need to incorporate a soupçon of non-ASCII
characters.
 
L

Lars Enderin

Arved said:
* I'm one to talk - if I read and write in my mother tongue I need äöüõ.

Which tongue is that? Not Swedish, it seems. Your name looks vaguely
Swedish, though.
 
A

Arved Sandstrom

Lars said:
Which tongue is that? Not Swedish, it seems. Your name looks vaguely
Swedish, though.
Estonian. My name however is 100% Swedish, and I'm about 1% Swedish.
Properly my last name is spelled Sandström.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top