Skip to Content.
Sympa Menu

freetds - Re: ISO-code translation

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Stefan Bodewig <bodewig AT bost.de>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: ISO-code translation
  • Date: 13 Apr 2000 11:14:41 +0200

>>>>> "BB" == Brian Bruns <camber AT umcc.ais.org> writes:

BB> There should really be a way to set this though like there is in
BB> dblib.

OK, this one is a rather quick hack, I guess you should also be able
to set the language or maybe other things.

Using the appended patch and the getConnection(URL, Property) method
in DriverManager it should be possible to set the charset. Just insert
a key-value pair with key="charset" into the supplied Property
instance.

The default will remain "iso_1".

Stefan

diff -ur /home/bodewig/freetds/freetds_jdbc/Connection_1_0.java ./Connection_1_0.java
--- /home/bodewig/freetds/freetds_jdbc/Connection_1_0.java	Sat Oct 23 10:41:22 1999
+++ ./Connection_1_0.java	Thu Apr 13 10:47:39 2000
@@ -51,6 +51,7 @@
         String   database_,
         String   user_,
         String   password_,
+        String   charset_,
         String   appName_,
         String   serverName_,
         String   progName_,
@@ -58,7 +59,7 @@
         Byte     progMinorVersion_)
         throws SQLException, com.internetcds.jdbc.tds.TdsException
    {
-      super(host_, serverType_.intValue(), port_.shortValue(), database_, user_, password_, appName_,
+      super(host_, serverType_.intValue(), port_.shortValue(), database_, user_, password_, charset_, appName_,
             serverName_, progName_, progMajorVersion_.byteValue(), progMinorVersion_.byteValue());
    }
 
@@ -70,6 +71,7 @@
       String   database_,
       String   user_,
       String   password_,
+      String   charset_,
       String   appName_,
       String   serverName_,
       String   progName_,
@@ -77,7 +79,7 @@
       byte     progMinorVersion_)
       throws SQLException, com.internetcds.jdbc.tds.TdsException
    {
-      super(host_, serverType_, port_, database_, user_, password_, appName_,
+      super(host_, serverType_, port_, database_, user_, password_, charset_, appName_, 
             serverName_, progName_, progMajorVersion_, progMinorVersion_);
    }
 }
diff -ur /home/bodewig/freetds/freetds_jdbc/Connection_2_0.java ./Connection_2_0.java
--- /home/bodewig/freetds/freetds_jdbc/Connection_2_0.java	Tue Jan 11 04:07:15 2000
+++ ./Connection_2_0.java	Thu Apr 13 10:48:03 2000
@@ -53,6 +53,7 @@
       String database_,        
       String user_,            
       String password_,        
+      String charset_,
       String appName_,         
       String serverName_,      
       String progName_,        
@@ -65,7 +66,8 @@
                port_,            
                database_,        
                user_,            
-               password_,        
+               password_,
+               charset_,
                appName_,         
                serverName_,      
                progName_,        
diff -ur /home/bodewig/freetds/freetds_jdbc/Connection_base.java ./Connection_base.java
--- /home/bodewig/freetds/freetds_jdbc/Connection_base.java	Tue Jan 11 04:12:35 2000
+++ ./Connection_base.java	Thu Apr 13 10:46:06 2000
@@ -90,6 +90,7 @@
    String database            = null;
    String user                = null;
    String password            = null;
+   String charset             = null;
    String appName             = null;
    String serverName          = null;
    String progName            = null;
@@ -140,6 +141,7 @@
      String database_,
      String user_,
      String password_,
+     String charset_,
      String appName_,
      String serverName_,
      String progName_,
@@ -153,6 +155,7 @@
       database            = database_;
       user                = user_;
       password            = password_;
+      charset             = charset_;
       appName             = appName_;
       serverName          = serverName_;
       progName            = progName_;
@@ -341,7 +344,7 @@
          try
          {
             tmpTds = new Tds(this, host, serverType, port, 
-                             database, user, password,
+                             database, user, password, charset,
                              appName, serverName, progName,
                              progMajorVersion, progMinorVersion,
                              sqlStatementForSettings());
diff -ur /home/bodewig/freetds/freetds_jdbc/Constructors.java ./Constructors.java
--- /home/bodewig/freetds/freetds_jdbc/Constructors.java	Tue Jan 25 18:33:52 2000
+++ ./Constructors.java	Thu Apr 13 10:49:36 2000
@@ -102,6 +102,7 @@
             java.lang.Class.forName("java.lang.String"),   // database
             java.lang.Class.forName("java.lang.String"),   // user
             java.lang.Class.forName("java.lang.String"),   // password
+            java.lang.Class.forName("java.lang.String"),   // charset
             java.lang.Class.forName("java.lang.String"),   // appName
             java.lang.Class.forName("java.lang.String"),   // serverName
             java.lang.Class.forName("java.lang.String"),   // progName
@@ -110,21 +111,20 @@
          };
          
          
-         if (java.lang.System.getProperty("java.version").startsWith("1.1"))
-         {
-            jdbcVersion     = JDBC1_0;
-            jdbcVersionName = "1_0";
-         }
-         else if (java.lang.System.getProperty("java.version").startsWith("1.2"))
+         try 
          {
+            Class statement = java.lang.Class.forName("java.sql.Statement");
+            java.lang.reflect.Method execBatch = 
+                statement.getDeclaredMethod("executeBatch", new Class[0]);
+
             jdbcVersion     = JDBC2_0;
             jdbcVersionName = "2_0";
-         }
-         else
+         } 
+         catch (NoSuchMethodException nsme) 
          {
-            // XXX What do we have here?  Should we throw an exception?
+            jdbcVersion     = JDBC1_0;
+            jdbcVersionName = "1_0";
          }
-         
 
          try
          {
@@ -264,6 +264,7 @@
         String database_,
         String user_,
         String password_,
+        String charset_,
         String appName_,
         String serverName_,
         String progName_,
@@ -286,6 +287,7 @@
             database_,
             user_,
             password_,
+            charset_,
             appName_,
             serverName_,
             progName_ ,
diff -ur /home/bodewig/freetds/freetds_jdbc/Driver.java ./Driver.java
--- /home/bodewig/freetds/freetds_jdbc/Driver.java	Sat Jan  8 05:25:27 2000
+++ ./Driver.java	Thu Apr 13 10:51:15 2000
@@ -261,6 +261,7 @@
                parseUrl(Url).getProperty("DBNAME"),
                info.getProperty("user"),              //username,
                info.getProperty("password"),          //password
+               info.getProperty("charset", "iso_1"),  //charset
                info.getProperty("APPNAME", "jdbclib"),
                info.getProperty("SERVERNAME", parseUrl(Url).getProperty("HOST")),
                info.getProperty("PROGNAME", "java_app"),
diff -ur /home/bodewig/freetds/freetds_jdbc/ResultSet_2_0_helper.java ./ResultSet_2_0_helper.java
--- /home/bodewig/freetds/freetds_jdbc/ResultSet_2_0_helper.java	Tue Jan 11 04:08:14 2000
+++ ./ResultSet_2_0_helper.java	Thu Mar 23 12:34:35 2000
@@ -4,7 +4,7 @@
 import java.sql.*;
 
 public interface ResultSet_2_0_helper 
-implements java.sql.ResultSet
+extends java.sql.ResultSet
 {
 
    public static final String cvsVersion = "$Id: ResultSet_2_0_helper.java,v 1.2 2000/01/11 03:08:14 cts Exp $";
diff -ur /home/bodewig/freetds/freetds_jdbc/Tds.java ./Tds.java
--- /home/bodewig/freetds/freetds_jdbc/Tds.java	Fri Mar 31 08:58:33 2000
+++ ./Tds.java	Thu Apr 13 11:07:07 2000
@@ -125,6 +125,7 @@
    String              database;
    String              user;
    String              password;
+   String              charset;
    String              appName;
    String              serverName;
    String              progName;
@@ -161,6 +162,7 @@
       String                                   database_,
       String                                   user_,
       String                                   password_,
+      String                                   charset_,
       String                                   appName_,
       String                                   serverName_,
       String                                   progName_,
@@ -177,6 +179,7 @@
       database         = database_;
       user             = user_;
       password         = password_;
+      charset          = charset_;
       appName          = appName_;
       serverName       = serverName_;
       progName         = progName_;
@@ -647,7 +650,7 @@
       comm.appendByte((byte)0);
 
       // charset
-      comm.appendString("iso_1", 30, (byte)0);
+      comm.appendString(charset, 30, (byte)0);
       comm.appendByte((byte)5);
 
       // notify on charset change



Archive powered by MHonArc 2.6.24.

Top of Page