Can I force JDBC Driver use UTF-8 Charset to encode?

The similiar way is in MySQL, like
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
Thanks,

You must describe your requirements in more details. There is generally nothing special in reading/writing into a database that has UTF-8 (AL32UTF8) as its database character set. Data is read into/written from String variables, which are encoded in UTF-16 by Java design. JDBC transparently converts between UTF-16 and UTF-8.
If you want to output a string into a file in UTF-8 encoding, it is no longer an Oracle problem but a normal Java programming issue. You need to create an appropriate OutputStreamWriter for your FileOutputStream.
new OutputStreamWriter( new FileOutputStream(file), "UTF-8" );
-- Sergiusz

Similar Messages

  • Can't load jdbc driver in servlet

    Dear All,
    I have tried to connect to MS SQL SERVER 2000 through JDBC DRIVER FOR
    SQLSERVER. However I receieved an error: can't load jdbc driver class:
    null.
    The following steps were what I did:
    1.Set up SQL Server and create a few tables and users.
    2.Config Server.xml
    Add the following codes in /tomcat/conf/Server.xml
    <Context path="/persistence" docBase="persistence" debug="0"
    reloadable="true">
              <Resource name="jdbc/persistenceDB" auth="Container"
    type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/PersistenceDB">
                   <Parameter>
                        <name>user</name>
                        <value>kitty</value>
                   </Parameter>
                   <Parameter>
                        <name>password</name>
                        <value>abc</value>
                   </Parameter>
                   <Parameter>
                        <name>driverClassName</name>
                        <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
                   </Parameter>
                   <Parameter>
                        <name>url</name>
    <value>jdbc:microsoft:sqlserver://localhost:1433;databaseName=persistence;selectMethod=cursor;</value>
                   </Parameter>
              </ResourceParams>               
    </Context>
    3.Config my web application's web.xml
    Added the following piece of code in WEB.XML
    <resource-ref>
    <res-ref-name>jdbc/persistenceDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    4.Use Datasource in my code
    package persistence.database;
    import java.sql.*;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import javax.servlet.ServletContext;
    import persistence.*;
    import com.microsoft.jdbcx.sqlserver.*;
    import javax.naming.Context;
    public class DatabaseAuthenticator implements Authenticator {
    private DataSource ds;
    public void init(ServletContext sctx) throws Exception {
    InitialContext init = new InitialContext();
    try{
         Context ctx = (Context) init.lookup("java:/comp/env");
    ds = (DataSource) ctx.lookup("jdbc/persistenceDB");
    } catch (Exception e) { e.printStackTrace();
    public User authenticate(String username, String password)
    throws AuthenticationException, UnknownException {
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs;
    try {
    if (ds != null) {System.out.println("Success to get
    datasource");
            } else {System.out.println("Failed");}
    System.out.println(ds.toString());
    try
    conn = ds.getConnection();     
    catch (Exception e)
    e.printStackTrace();
    pstmt = conn.prepareStatement("SELECT user_id " + .........
    5. put msutil.jar, mssqlserver.jar and msbase.jar under /tomcat/common/lib/.
    When I tried to run the program, I receieved an error: can't load jdbc
    driver class: null.
    I've got no idea what's going on.
    Any Suggestion?
    Thanks in advance
    Kitty

    Hi Kitty,
    The connection you're trying to set up points to nothing :
    Connection conn = null;
    So, you receive a complaint that that driver cannot be loaded. Please read
    http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
    download the right database driver and use that. Good luck!
    Wouter van Reeven
    public User authenticate(String username, String
    g password)
    throws AuthenticationException, UnknownException
    ption {
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs;

  • How to know which type of jdbc driver used in my application

    How to know which type of jdbc driver used in my application.

    My approach will be....
    Type1: you have to have ODBC s/w install on your machine...even the connection string starts with jdbc:odbc....so it can be identifed easily
    Type2: you have to install client s/w in your machine...if you are using oracle oci driver ...you need to install oracle client s/w
    Type3: you use servername / port to connnect to middleware
    Type4: you do not need any client s/w
    So, If your application works without any client s/w on your machine....you might be using Type4/Type3 driver.....otherwise Type2
    Someone pls add more ....

  • How can i install jdbc driver

    Hi
    i install websphere 5 and try to connect to my sql server but cannot find jdbc driver class path and can not find any jdbc driver
    pls tell me how can i install jdbc driver in my websphere
    with regards

    You may get a better response posting this question in a WebSphere specific forum. Maybe this will help, the following link shows the command you need to execute to install a JDBC driver in websphere 5.0.
    http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?tab=search&searchWord=mysql+driver&maxHits=50

  • Itunes and proxy settings. Itunes keeps the proxy setting from IE and I can't adapt it due to company policy. How can I force itunes to use firefox?

    itunes can not connect to server and I can't find its proxy settings.
    So I think it uses these from IE and those are blocked by company policy.
    So, how can I force itunes to use the firefox settings

    I fixed this issue (with help from tech support) and it involved several things.
    After adding a song to iTunes, right-click on the song in iTunes and select "Update iTunes Match."
    OR go to the iTunes menu-->Store-->Update iTunes Match.
    Maybe that's the reason, it just hadn't updated to the cloud.
    OR maybe it's not a high-enough bitrate file.   This happens to me because most of my tunes are home-recorded.
    Sometimes converting to .mp3 or Create AAC version might work. (You do this with a right-click in iTunes, and then you will want to remove the original file from iTunes.)
    There is an iTunes Preferences setting, under General Preferences called Import Settings.  Try setting it to AAC Encoder and iTunes Plus.   That (I think) causes imports to be slightly better quality.
    Good luck!  The tech support person at Apple is requesting that a knowlege-base article be written about this.

  • Developing a 2 page form, username on the 1st page, password on 2nd how can i force FF to use the username from previous page when it asks to remember acct info?

    I am developing a 2 page signup form, where the person enters their username on the 1st page and password on the 2nd.
    When I test the form, FF asks to remember my password for the site - however it thinks the zipcode (field above the password) is the username on the account.
    I have tried to put their username/email in a hidden field on the 2nd page, just above the password field - and that did not work.
    How can i force FF to use the username from previous page when it asks to remember acct info?

    This website is using autocomplete=off to prevent Firefox from saving and filling the name and password.
    You can remove autocomplete=off with a bookmarklet to make Firefox save names and passwords and other form data.
    *http://kb.mozillazine.org/User_name_and_password_not_remembered

  • Error when going to install jdbc driver using JSPM

    Hi All,
    I am trying to Install JDBC driver using JSPM but its show error like
    <component location="\\xxxxxx\sapmnt\trans\EPS\in\com.sap.aii.adapter.lib.sda" status="ABORTED" dplorder="0" description="1. Runtime name of component [sap.com~com.sap.aii.adapter.lib] is changed from [sap.com~SAP-XI3RDPARTY~com.sap.aii.adapter.lib] to [com.sap.aii.adapter.lib]. Please, first remove the DC and then proceed with deployment" vendor="sap.com" name="com.sap.aii.adapter.lib" csn="BC-XI-CON-AFW" type="DC" version="7.3001.20110318104827.0001" size="0">
    I have also searched for sap.com~SAP-XI3RDPARTY~com.sap.aii.adapter.lib but nothing found. Please suggest how to remove DC?

    Hi Batra,
    Thanks for quick reply.
    I already followed the second link given by you and My jdbc driver installed properly first time but the jdbc adapter was not showing in communication channel. Only RFC and SOAP are showing there. In second link  com.sap.aii.adapter.lib  showing under SAP-XI3RDParty under software Component column but in my system it's not showing there .Software Component column coming blank in my case. So I add additional property Software Component in provider.xml whose value was sa.com/SAP-XI3RDPARTY and deployed it again using JSPM. Now jar deployed  in folder sap.com~SAP-XI3RDPARTY~com.dap.adapter.lib/lib rather than com.dap.adapter.lib/lib. So I removed property Software Component and tried to deploy again but now showing the problem
    <component location="\\xxxxxx\sapmnt\trans\EPS\in\com.sap.aii.adapter.lib.sda" status="ABORTED" dplorder="0" description="1. Runtime name of component [sap.com~com.sap.aii.adapter.lib] is changed from [sap.com~SAP-XI3RDPARTY~com.sap.aii.adapter.lib] to [com.sap.aii.adapter.lib]. Please, first remove the DC and then proceed with deployment" vendor="sap.com" name="com.sap.aii.adapter.lib" csn="BC-XI-CON-AFW" type="DC" version="7.3001.20110318104827.0001" size="0">
    However I have deleted folder sap.com~SAP-XI3RDPARTY~com.sap.aii.adapter.lib.

  • Change JDBC driver used by OC4J

    Hi all,
    I did some testing of the different Oracle JDBC driver classes -- including "classes12.zip", "ojdbc14.jar" and "classes12dms.jar" -- in a plain old java class (nothing to do with OC4J). It seems to me that the "classes12.zip" file gives the best performance, so I was wondering if it is a good idea to make OC4J use this driver (instead of the "classes12dms.jar" file). If this is a good idea, then how can I make OC4J use the "classes12.zip" file (instead of the "classes12dms.jar" file) ?
    For your information, I am using OC4J stand-alone 10.0.3 on SUN [sparc] solaris 9 with Oracle 9i (9.2.0.4) database and java version 1.4.2_02.
    Thanks (in advance),
    Avi.

    Hi all,
    I did some testing of the different Oracle JDBC
    driver classes -- including "classes12.zip",
    "ojdbc14.jar" and "classes12dms.jar" -- in a plain
    old java class (nothing to do with OC4J). It seems to
    me that the "classes12.zip" file gives the best
    performance, so I was wondering if it is a good idea
    to make OC4J use this driver (instead of the
    "classes12dms.jar" file). If this is a good idea,
    then how can I make OC4J use the "classes12.zip" file
    (instead of the "classes12dms.jar" file) ?
    For your information, I am using OC4J stand-alone
    10.0.3 on SUN [sparc] solaris 9 with Oracle 9i
    (9.2.0.4) database and java version 1.4.2_02.
    Thanks (in advance),
    Avi.gday again Avi -- funny to see you posting questions instead of answering them!
    OK, here's the scoop.
    In the releases of the product to date (including the current developer preview) we've hardcode the JDBC class library (classes12dms.jar) into the Class-Path setting in the Manifest.mf file of the oc4j.jar file. This basically makes the one JDBC library load at the container level and is therefore used by all applications running on the product. This is done since some of the classes which are loaded by OC4j at the container level have a dependency on classes in the JDBC library, so they need to be available.
    The only way to change this is to :
    a) overwrite the classes12dms.jar with the the JDBC library you want to use -- ie rename the one you want to classes12dms.jar and put it in the directory where classes12dms.jar currently resides.
    b) open up the Manifest.mf in the oc4j.jar file and alter the Class-Path so it points to JDBC lib you want to use.
    I can't comment authoritavely on the supportability of either of these two tasks, but I suspsect that doing either of these would put you into an unsupported mode.
    But that doesn't concern you since you're running with a developer preview anyway ;-).
    The good news is that with the production release (or even another developer preview update) we'll have in place our new shared libary model. This will enable us to separate in a very clean way what is a system library and what are application libraries. We'll be able to setup and configure libraries that are available to applications which will not conflict with any libraries that are loaded at the container level. The new libs will be able to be shared by all or any subset of deployed applications if needed. It's quite an elegant and very powerful feature.
    So hack around today, but look forward to our next update of the 10.0.3 (which has recently be re-versioned to 10.1.3 for consistency across Oracle) release.
    cheers
    -steve-

  • Beginner Has Problem With Loading JDBC Driver Using MySQL

    Hi, I am having problem with loading JDBC driver, and need your diagnotic help.
    1. I have installed MySQL (C:\mysql), created a databse (soup), and created a littel table (VIDEOS). I am able to see the table in the console:
    sql> select * from videos
    2. I have downloaded the latest version of Connector/J (mysql-connector-java-3.1.0-alpha.zip), and unzip the zip file into my C:\ directory.
    3. I copied the mysql-connector-java-3.1.0-alpha-bin.jar to the C:\j2sdk1.4.1_02\jre\lib\ext folder and it is in my CLASSPATH
    4. MySQL server is running
    C:\> C:\mysql\bin\mysqld-nt --standalone
    5. open another DOS window and use the database
    mysql>USE SOUP
    6. succesfully compiled a Java program (javac Test.java):
    import java.sql.* ;
    public class Test
    public static void main( String[] args )
    try
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    try
    Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/soup" );
    try
    Statement statement = con.createStatement();
    ResultSet rs = statement.executeQuery("SELECT TITLE FROM VIDEOS");
    while ( rs.next() )
    System.out.println( rs.getString( "TITLE" ) );
    rs.close();
    statement.close();
    catch ( SQLException e )
    System.out.println( "JDBC error: " + e );
    finally
    con.close();
    catch( SQLException e )
    System.out.println( "could not get JDBC connection: " + e );
    catch( Exception e )
    System.out.println( "could not load JDBC driver: " + e );
    7. when I run the Java program (java Test), I got
    the message:
    could not load JDBC driver: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    What am I missing?

    Hi,
    I missed to specify test in my last post.
    Try running your program by explicitly setting the classspath when
    running your program . java -classpath c:\mysql-connector-java-3.1.0-alpha-bin.jar test
    Make sure your jar file contains org.gjt.mm.mysql.Driver class

  • Can't load JDBC Driver

    Hi,
    I can't load my JDBC driver for SQLserver database to
    opening my DB with a servlet ...
    platform : Windows 2000 server
    servlet container : Jakarta-tomcat 3.2.2
    jdk : jdk1.3
    After executing the servlet which load the JDBC driver, the following message was appearing:
    "ClassNotFoundException, java.lang.NullPointerException"
    Thanks for your help.

    Looks like the servlet is not able to find the required class in the package...Tomcat rewrites the classpath....So you might want to look at /bin/tomcatEnv.bat     and modify it accordingly....Of course, check your classpath env variable to see if all the necessary zip/jar files are included.

  • Can't load jdbc driver from localhost

    I'm having problems loading the jdbc driver from localhost when using a java com object in ASP.
    The simple class compiles fine and runs perfect from dos command line but gives this exception when run from personal webserver:
    java.lang.ClassNotFoundException: sun/jdbc/odbc/JdbcOdbcDriver
    Obviously, it is not finding the jdbc driver, but what is the problem? It finds the driver when run from dos locally. Do I need a 3rd party driver when using as a COM object?
    Here is a code snippet:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection TestConnection = DriverManager.getConnection("jdbc:odbc:systemDSN", "username", "password");
    Any help is appreciated, thanks!

    I don't think it's exactly a classpath problem. I think when you run from the DOS command line, you are using the java.exe program that contains Sun's JVM and all the associated classes including sun/jdbc/odbc/JdbcOdbcDriver. But when you use this Java COM object (which I am not familiar with), if it doesn't find that class then it must be using the Microsoft VM, which naturally doesn't include that class you are having a problem with.

  • Adobe plugin removed. Defaults set to Adobe Standard. I get Firefox demand to install plugin. How can I force Adobe to use Standard?

    Adobe Reader won't open certain (large) Adobe files.
    > I set all Firefox defaults to Adobe Standard. Firefox still uses Adobe Reader.
    > Uninstalled Adobe Reader. Uninstalled Firefox Adobe plugin.
    > When I try to open an Adobe File, Firefox now says to install Adobe Plugin.
    ... catch - 22.
    What can I do to force Firefox to use Adobe Standard? (none of the moderator solutions appear to work)

    RESOLUTION (seems not logical, but this worked):
    Firefox would do nothing other than ask me to install the Firefox plugin for Adobe, which I accepted. This process leads to re-installing Adobe Reader. After installing Adobe Reader, all of the defaults that I previously had set to use Adobe Standard were re-set during the Adobe Reader installation to use Adobe Reader interally in Firefox.
    After re-installing, I was able to load the document that previously I was unable to load (using Adobe Reader inside Firefox). I changed all of the Adobe defaults (under TOOLS/OPTIONS) to "always use Adobe Standard" instead of "Use Adobe Reader (default)". I was then able to open the document using Adobe Standard.
    It appears that the following process solved the problem:
    > uninstall Adobe Reader
    > reinstall Adobe Reader (and the Firefox Adobe plugin)
    > change the defaults from "Use Adobe Reader (default)" to "Adobe Standard [release number]"
    Note: I have Firefox 21.0 installed, and Adobe Reader XI 11.0.3 installed prior to, and after, this issue.

  • Can I force Leopard to use a different python installation

    I should have posted here initially at the Unix board...
    Dumb question: Will Leopard use a different python install in bash than the python used by an ordinary GUI application? I want control over which python install the GUI application uses.
    Does anyone know how to force Leopard to use a macports installation of python instead of the default Apple installation? I know how to get the shell to use it, by putting an "export" line into the ~/.profile file, or adding a .bash_profile file to ~/
    and the bash shell will use my macports install of python. However when I use an application called blender
    www.blender.org
    which relies on python for some operations, it refuses to recognize some python modules installed in the macports version of python, which can be running simultaneously in bash. The python shell in Terminal says the module has been imported because there is no error message, but blender and the Console both say the module was not recognized by blender. Is it possible that the application blender has been compiled in such a way that it will only look for leopard's version of python? Is there a way to get leopard's python to take into account the mess of folders in macports python so that it can use the files therein? I've already tried putting the +/opt/local/bin, sbin, lib,+ and include folders into the path returned by env.
    Refers to the macports python 2.5.4 and the current leopard python 2.5.1

    I'm not using MacPorts, and don't know how MacPorts installs Python. Is it installed in the form of framework?
    /opt/local/Library/Frameforks/Python.framework/Python.framework/
    If this is the case, then I guess you can tell blender to use this framework (instead of the Leopard's default framework) by setting the evironment variable DYLDFRAMEWORKPATH to "/opt/local/Library/Frameworks". Of course there is a possibility that the framework installed by MacPorts is not compatible with the blender.
    But there is another problem; if you start blender by double-clicking on its icon, the environment variables set in your shell have no effect. You can set environment for GUI apps in ~/.MaOSX/environment.plist, but it will affect all the GUI apps so it is rather dangerous (if a framework in /opt/local/Library/Frameworks/ is broken, then many apps won't run correctly). So the first thing you may try is to start blender from the command line:
    $ export DYLDFRAMEWORKPATH=/opt/local/Library/Frameworks
    $ /Applications/blender.app/Contents/MacOS/blender
    Of course the "$" above is the prompt of your shell, and you need not type it. If you have installed blender.app in a different folder then modify the path accordingly.

  • How can I control a driver using Matlab?

    For a lab project I have to program in matlab a driver (esp300 by Newport - http://www.newport.com/store/product.aspx?id=3229) that commands a motorized stage of the same company. The interface is GPIB. I rather control the driver using only matlab, but if i can't - i wan't to use Labview as a connector between the two. any idea how can i do one of the above? I've got no idea where to start from. I'll thank to any given advise. 

    What is the analysis that ou need to perform. The resources that are available to you from within LV is very complete!
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Is it supported to use Microsoft JDBC driver use in Java 7 (and 8) multithreaded applications?

    Hello everone
    is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    I am planning to use standard Java 7 threads library and use separate JDBC objects per each thread, i.e. Java threads will not share any JDBC objects among them, only the thread-safe Java collections/data structures will be shared between threads (such as
    ConcurrentHashMap etc). The JDBC connections, resultsets, statements, etc will be created and dedicated per each individual thread.
    If it is supported - do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Thanks
    Yuri Budilov
    Yuri Budilov Melbourne Australia

    >is it supported to use Microsoft JDBC driver (the latest version) with Java 7 multithreaded application?
    Yes, so long as:
    > Java threads will not share any JDBC objects among them,
    >do you expect this design to scale-up well or am I better off using multiple but single-threaded Java/JBDC programs >to access SQL Server 2012/2014 from Microsoft JDBC driver?
    Using threads should scale better than using processes (at least on Windows), as there is quite a bit of overhead with a process.  Each process has it's own JRE, it's own GC heap, its own threads...
    The bigger question, though, is how this scales on the SQL Server.  Your throughput may be limited by resources on your database server, and the thread's workloads may not be able to run concurrently because of locking. 
    David
    David http://blogs.msdn.com/b/dbrowne/

Maybe you are looking for