About jdbc enconding ...

          Hi !
          I got a very strange problem...
          I am using wls 6.0 sp2 in a Sun machine, Oracle 8.1.6
          and i got a problem with encoding charset ...
          When i use a simple sentecen createStatement, i can see
          all datas from database ok, but when i use cursor
          data it changed to the asciii representation, and then i see a sequence of numbers
          I revised all configuration, charset from bbdd is ok...
          what is it ?
          jsanza
          

The Sun Javasoft web site is a good place to start. The following URL
http://web2.java.sun.com/docs/books/tutorial/jdbc/index.html
Will take you directly to the JDBC tutorial.

Similar Messages

  • ####a question about jdbc driver

    A question about jdbc driver: for Oracle JDBC drivers which will not allow O/R
    tools to access columns over 4 kb. This affects some of the functionality of my
    application.A workaround is to use the my JDBC driver that acts as a wrapper to
    ensure that columns over 4 kb read and persist properly. my JDBC driver determines
    which actual driver to load based on the connection URL. If you pass in a URL
    that contains the string jdbc:oracle:thin, it will know to load oracle.jdbc.driver.OracleDriver.
    If the URL contains the string jdbc:db2, it will know to load COM.ibm.db2.jdbc.net.DB2Driver,
    and so on.
    now i have set CLASSPATH for my jdbc wapper,when I Creating and Configuring a
    JDBC Connection Pool,i have to input my driver name such com.lawrence.driver.....then
    i did,all
    is well,then i restart my WLS,when load config.xml,some errors such as "No registered
    driver accept URL:jdbc:oracle:thin:@localhost:1521:lawrence",if i set driver name
    is oracle.jdbc.driver.OracleDriver,all is good,no any errors.
    I find some questions like:
    1.for WLS8.1 ,it is only find some registed driver?
    2.why it cannot load my driver wapper when it is loading jdbc Connection Pool,but
    when the WLS start is finished, i Creating and Configuring a JDBC Connection Pool
    then it is right?

    my JDBC driver like this:
    public class myDriver implements Driver {
         public static String DB2_DRIVER = "COM.ibm.db2.jdbc.net.DB2Driver";
         public static String DB2_URL = "jdbc:db2:";
         public static String HYPERSONIC_DRIVER = "org.hsqldb.jdbcDriver";
         public static String HYPERSONIC_URL = "jdbc:hsqldb:";
         public static String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
         public static String MYSQL_URL = "jdbc:mysql:";
         public static String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver";
         public static String ORACLE_URL = "jdbc:oracle:";
         public static String POSTGRESQL_DRIVER = "org.postgresql.Driver";
         public static String POSTGRESQL_URL = "jdbc:postgresql:";
         public static String SQLSERVER_DRIVER =
              "com.microsoft.jdbc.sqlserver.SQLServerDriver";
         public static String SQLSERVER_URL = "jdbc:microsoft:";
         public boolean acceptsURL(String url) throws SQLException {
              return true;
         public synchronized Connection connect(String url, Properties props)
              throws SQLException {
              if (_driver == null) {
                   Class driverClass = null;
                   try {
                        if (url.startsWith(DB2_URL)) {
                             driverClass = Class.forName(DB2_DRIVER);
                        else if (url.startsWith(HYPERSONIC_URL)) {
                             driverClass = Class.forName(HYPERSONIC_DRIVER);
                        else if (url.startsWith(MYSQL_URL)) {
                             driverClass = Class.forName(MYSQL_DRIVER);
                        else if (url.startsWith(ORACLE_URL)) {
                             driverClass = Class.forName(ORACLE_DRIVER);
                        else if (url.startsWith(POSTGRESQL_URL)) {
                             driverClass = Class.forName(POSTGRESQL_DRIVER);
                        else if (url.startsWith(SQLSERVER_URL)) {
                             driverClass = Class.forName(SQLSERVER_DRIVER);
                        _driver = (Driver)driverClass.newInstance();
                   catch (Exception e) {
                        throw new SQLException(e.getMessage());
              Connection con = _driver.connect(url, props);
              return new myConnection(con);
         public int getMajorVersion() {
              return _driver.getMajorVersion();
         public int getMinorVersion() {
              return _driver.getMinorVersion();
         public DriverPropertyInfo[] getPropertyInfo(String url, Properties props)
              throws SQLException {
              return _driver.getPropertyInfo(url, props);
         public boolean jdbcCompliant() {
              return _driver.jdbcCompliant();
         private Driver _driver;

  • About JDBC

    Hi, I am a fresher studying about JDBC. I wanted to know about the basics of JDBC. i wanted to know for what purpose JDBC is used..

    hi
    there r diffrent types of jdbc connection.hope u kmow jdbc is use to connect to database.if u need jdbc -mysql connection
    1.download a mysql connector from apache site
    2.edit .bash profile and add patf of connector to classpath
    3.follow this link http://www.kitebird.com/articles/jdbc.html#TOC_1

  • About JDBC Drivers

    Hello,
    I am not have a clear idea about JDBC drivers , Any one Give the diff between the four types and where we use ,which is best ..................plz make a reply

    "JDBC drivers in the wild
    Learn how to deploy, use, and benchmark JDBC driver types 1, 2, 3, and 4 " at
    http://www.javaworld.com/javaworld/jw-07-2000/jw-0707-jdbc.html
    Good work.

  • A very surprise problem about JDBC and connection pool

    I occur a very problem about JDBC and connection pool on Weblogic Platform
    8.1.
    There is a table in Oracle
    Table
    Name: t1
    id varchar2(5);
    content clob;
    id is primary key.
    If I use a connection pool to connect to Oracle,like following program:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
    con = ds.getConnection();
    then following program will throw a ClassCastException
    String sql = "select content from t1 where id = ?";
    PreparedStatement pst = con.prepareStatement(sql);
    pst.setString(1,"001");
    oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
    statement will throw ClassCastException
    but if I use JNDI to connect to Oracle,like following program, then those
    program above is ok
    private String dbdriver="oracle.jdbc.driver.OracleDriver";
    private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
    private String username="ep";
    private String password="epuser";
    Class.forName(dbdriver);
    conn = DriverManager.getConnection(dburl, username, password);
    conn.setAutoCommit(false);
    On the contrary, if I use JNDI to connect to Oracle, following program will
    throw ClassCastException
    weblogic.jdbc.vendor.oracle.OracleThinClob clob =
    (weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
    but it is fine if I use connection pool to connect to Oracle.
    I am confused this problem, who can tell me why?
    Daniel

    When you are getting connection using datasource lookup from weblogic
    connection pool, this connection is internally wrapped and hence you have to
    cast it to weblogic.jdbc.vendor.oracle.OracleThinClob which you do and so it
    works.
    But when you get connection by loading driver straight, you are getting naked
    oracle connection. In this case when you cast it to oracle.sql.Clob it works,
    as you have seen in your test case.
    I hope this explains what is going on with your code.
    Thanks,
    Mitesh
    Daniel wrote:
    I occur a very problem about JDBC and connection pool on Weblogic Platform
    8.1.
    There is a table in Oracle
    Table
    Name: t1
    id varchar2(5);
    content clob;
    id is primary key.
    If I use a connection pool to connect to Oracle,like following program:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("cgOracleDataSource");
    con = ds.getConnection();
    then following program will throw a ClassCastException
    String sql = "select content from t1 where id = ?";
    PreparedStatement pst = con.prepareStatement(sql);
    pst.setString(1,"001");
    oracle.sql.CLOB clob = (oralce.sql.CLOB)rs.getClob("content") //this
    statement will throw ClassCastException
    but if I use JNDI to connect to Oracle,like following program, then those
    program above is ok
    private String dbdriver="oracle.jdbc.driver.OracleDriver";
    private String dburl="jdbc:oracle:thin:@192.168.7.148:1521:ep";
    private String username="ep";
    private String password="epuser";
    Class.forName(dbdriver);
    conn = DriverManager.getConnection(dburl, username, password);
    conn.setAutoCommit(false);
    On the contrary, if I use JNDI to connect to Oracle, following program will
    throw ClassCastException
    weblogic.jdbc.vendor.oracle.OracleThinClob clob =
    (weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("content");
    but it is fine if I use connection pool to connect to Oracle.
    I am confused this problem, who can tell me why?
    Daniel

  • About jdbc and networking

    hi, i found this error while im generating a report
    for my system, "Aging of Accounts Receivables"
    hope someone might give me a hint to what should i do.
    here's my StackTrace:
    ***Exception:
    org.postgresql.util.PSQLException: The connection attempt failed because Exception: java.net.BindException: Address already in use: connect
    Stack Trace:
    java.net.BindException: Address already in use: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:179)
    at org.postgresql.core.PGStream.<init>(PGStream.java:47)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197)
    at org.postgresql.Driver.connect(Driver.java:139)
    org.postgresql.util.PSQLException: The connection attempt failed because Exception: java.net.BindException: Address already in use: connect
    Stack Trace:
    java.net.BindException: Address already in use: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.<init>(Socket.java:366)
    at java.net.Socket.<init>(Socket.java:179)
    at org.postgresql.core.PGStream.<init>(PGStream.java:47)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197)
    at org.postgresql.Driver.connect(Driver.java:139)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    End of Stack Trace
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:208)
    at org.postgresql.Driver.connect(Driver.java:139)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:72)
    at org.postgresql.jdbc2.optional.BaseDataSource.getConnection(BaseDataSource.java:55)
    at org.postgresql.jdbc3.Jdbc3ConnectionPool.getPooledConnection(Jdbc3ConnectionPool.java:39)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getPooledConnection(PoolingDataSource.java:406)
    at org.postgresql.jdbc2.optional.PoolingDataSource.getConnection(PoolingDataSource.java:338)
    at csfwdbillingmodules.dbConnect.<init>(dbConnect.java:73)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:794)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:406)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.doInBackground(frmAgingOfAccounts.java:400)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    java.lang.NullPointerException
    at csfwdbillingmodules.dbConnect.query(dbConnect.java:96)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.processAccountAR(frmAgingOfAccounts.java:798)
    at csfwdbillingmodules.frmAgingOfAccounts$genAgingOfAccounts.genDetailedReport(frmAgingOfAccounts.java:1102)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at javax.swing.SwingWorker.run(SwingWorker.java:319)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
    at java.lang.Thread.run(Thread.java:619)
    End of Stack Trace
    here's my dbConnect.class:
    * dbConnect.java
    * Created on November 14, 2006, 5:06 PM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author darkoasis
    package csfwdbillingmodules;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.InetAddress;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.net.SocketAddress;
    import java.net.SocketException;
    import java.net.SocketImpl;
    import java.sql.*; // All we need for JDBC
    import javax.naming.NamingException;
    import org.postgresql.jdbc3.Jdbc3PoolingDataSource;
    public class dbConnect
    extends java.lang.Object
    private Socket socket;
    private SocketImpl socketImpl;
    private int refPosition = 0;
    private Jdbc3PoolingDataSource source = new Jdbc3PoolingDataSource();
    private DriverManager drvMgr;
    private Connection db = null; // A connection to the database
    private Statement sql; // Our statement to run queries with
    private ResultSet results; // A result container
    private DatabaseMetaData dbmd; // This is basically info the driver delivers
    // about the DB it just connected to. I use
    // it to get the DB version to confirm the
    // connection in this example.
    /** Creates a new instance of dbConnect */
    public dbConnect()
    try
    this.source.setServerName("10.10.10.10");
    this.source.setDatabaseName("myDB");
    this.source.setUser("xxxx");
    this.source.setPassword("xxxx");
    this.db = this.source.getConnection();
    this.socket = new Socket();
    dbmd = this.db.getMetaData(); //get MetaData to confirm connection
    sql = this.db.createStatement(); //create a statement that we can use later
    catch (Exception ex)
    System.out.println("***Exception:\n"+ex);
    ex.printStackTrace();
    public ResultSet query(String strSQL)
    throws SQLException
    this.results = this.sql.executeQuery(strSQL);
    return this.results;
    public void update(String strSQL)
    throws SQLException
    this.sql.executeUpdate(strSQL);
    public void close()
    throws Exception
    this.db.close();
    this.socket.close();
    this.source.close();
    public boolean isClosed()
    throws SQLException
    return this.db.isClosed();
    i ran into some forums and found this:
    Hi Graham
    I'm making a bit of progress. I found a website that suggested the following
    This is a problem of the used sockets with Windows NT. You can request the active sockets with the command netstat. The problem is a function of:
    MaxUserPort (default 5000)
    KeepAliveTime (default 120)
    it suggested the workaround was connection pooling
    I have run netstat to look at the number of connections when the problem occurs and waited for the timeout to reset the os back to the minimum and on each occasion my report has run
    Does this sound logical?
    If so
    do you have any examples on connection pooling
    it seems that even if i have closed my database connection it still doesn't free my port that was used, that's why i get this error
    i am looking for a way to close my db connection and free its socket or port used at the same time, hope you can help,
    thanks in advance

    Let me modestly point you at mine: http://www.telekinesis.com.au/wipv3_6/FundamentalNetworkingInJava.A21

  • About jdbc url question

    the questions:
    i want to make a connect to mysql database sever.
    i use jdbc:odbc dirver
    and it works like following;
    String url = "jdbc:odbc:mysql_dsn";
    ..here i define mysql_dsn in windows control panel->ocbc
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    i want to ask if i want to use an other URL format
    like
    jdbc:odbc://localhost:3306/mysql
    it does not work!
    please be kind to answer the question.it confuse me for a long time.
    and if possible please give me more example for the URL format..
    thanks in advance.
    niko

    In your particular case (where you're using the JDBC/ODBC bridge), the java pieces don't have any knowledge about how your real driver (the ODBC driver) connects to the database. Java doesn't know if there is a file-based DB (like MS Access or Paradox) or a Server database (such as SQL Server) behind the bridge. What java (or the bridge) DOES know is how to 'talk ODBC'. Even then, the BRIDGE doesn't know all the settings for the ODBC driver (only the driver itself knows, because it pulls it from the DSN configuration).
    You might be able to tweak the connection by using the Properties object that you pass along, as the bridge may pass these to the ODBC driver and you might be able to override the DSN settings.

  • The Question Set about JDBC Adapter

    Hello Experts,
    I have some confusion about the JDBC Adapter as below, pls help me :
    1. While the JDBC Sender Channel is executing the select statement then I interrupt it, if the ResultSet ought to have 5000
        records, so I stop the Channel that it just can select 3000 records.
        I wanna know if the 3000 records will go ahead to the Receiver Channel ?
    2.If there are 7000 records ought to insert DB via JDBC Receiver Channel, but I interrupt the Receiver Channel when it is
       running, now there are 4000 records have be insert DB (I know it doesnt commit, because I dont choose the option of
       u201CAuto-Commit-Enabledu201D in the Communication Channel), then what will occur ??
       a rollback? or commit? or other circs?
    3.By the way, the sender channel have sent some Msgs but the receiver channel is stopped now, I dont wanna the
       Receiver Channel getting the Msgs when start the Receiver channel, how can I get the goal?
    THX for ur time and effort,
    Brian

    Hi Brain,
    3.By the way, the sender channel have sent some Msgs but the receiver channel is stopped now, I dont wanna the
    Receiver Channel getting the Msgs when start the Receiver channel, how can I get the goal?
    In order to achieve this go to RWB --> Message Monitoring --> Search your Messages and Cancel all the Messages before you START the Reciever Channel.
    Once the messages are canceled.....you can START the Reciver Channel it will not receive them.
    Cheers
    Dhwani

  • About JDBC API

    "The JDBC API contains two major sets of interfaces:
    the first is the JDBC API for application writers,
    and the second is the lower-level JDBC driver API for driver writers.
    Applications and applets can access databases via the JDBC API using pure Java JDBC technology-based drivers."
    You can read this in the sun web site.
    When I have downloaded a jdbc driver for mysql database
    I have looked for source code and found those classes that implement the different interfaces belonging to package java.sql:
    at this point I imagine that this driver implements the first of the two interfaces in the previous sentence.
    I have not understood when the driver API for driver writers enter in this schema and if the second interface is anyway necessary for interact with the database: I would think that the second interface is necessary and is built with the driver API for driver writers, API that I have never seen.
    What do you think about this?

    I was thinking the same but now I am not so sure.
    Are you sure that API that belong to JDBC Driver API are not simply those concerning the driver manager?
    Anyway, when I download the driver in order to speak with the database, are there JDBC Driver API too?
    If you had reason, and the second volume of my official tutorial seems confirm this, the two interfaces would be completly separate.
    And I can not imagine a API that help me writing a driver for any database. Which type of help could give me?

  • Who can help me?I have a question about JDBC with SQL Server 2000.

    import java.sql.*;
    import java.util.*;
    public class sqltest{
    static public void main(String args[]){
    try{
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    }catch(Exception e){
    e.printStackTrace();
    return;
    try{
    Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://CE800:1181;UseDatabaseName=supermarket;user=sa;Password=");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from customers");
    while(rs.next()){
    System.out.println(rs.getString("username"));
    conn.close();
    }catch(Exception e){
    e.printStackTrace();
    return;
    when I run it,error occured:
    D:\MyJava\sql>java sqltest
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'customers'.
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.processReplyToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
    at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
    at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
    at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
    at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
    at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
    at com.microsoft.jdbc.base.BaseStatement.executeQuery(Unknown Source)
    at sqltest.main(sqltest.java:15)
    Please help me,thanks a lot!

    Your code seems ok, you probably end up in another Database than you expect.
    Not sure about the the UseDatabaseName=supermarket clause in your connection string.
    You can confirm that get a connection to another database by changing your query to:
    SELECT * FROM supermarket.dbo.customers
    if this works you probably get a connection to master and should look closer at the UseDatabaseName=supermarket clause.
    You did try to run the query in the Query Analyzer i take it?
    Rgds

  • Questions about JDBC-Drivers

    Hi,
    I'm working with JDBC-Drivers for the first time.
    How can I get detailed information about the database, subprotocol etc. the driver supports. In ODBC there exist some information functions like SQLGetInfo to explore drivers. But there seems to be no way to do this with JDBC.
    Can anybody give me some advice how to get this information ?
    J�rgen

    Hi,
    after instantiating an object implementing the Driver interface I want to know what database this driver works for. If possible, this should be done without connecting to the database. I supposed a driver should store such information in itself but there seems no way to get this information.
    The Driver interface declares a method 'getPropertyInfo' to extract information about the possible properties for this driver. Unfortunately I didn't found any description what lookup strings can be used.
    Do you know how to go on ?
    Thanks and regards
    Jugi

  • A question about JDBC and MySQL

    hello dear friends,ask a question:
    if in MySQL database, i have defined a clumon as TEXT data type.
    when i use JDBC, i use which kind of java data type to hold TEXT,
    i mean which getXXX() method i should use.
    is it possible i just use getObject() and cast it to a binarystream??
    thanks in advanced.

    use this:
    declare it 1st
    String x ="";
    then u can now get the value of the field...
    x = getString("<fieldName>");is there length limitation?
    for example, i want store a String which is got from a JTextArea, i also treat it as String and insert into the column with TEXT datatype like
    insert table_name (text_column) values( string_1)
    this works in JSP, should work in JAVA too...
    hope i helped... ^_^

  • About JDBC ODBC bridge

    I'm developing an application using EJBs in a development environment with Sun Application Server, Sql Server and NetBeans IDE 4.1. I'm using entity beans and session beans in my application. But, when I try to connect to database using a Servlet or JSP with the session beans, the connection with database could not be established. This is my problem!!!

    First, you probably shouldn't use the JDBC/ODBC bridge. Any serious and many non-serious databases have real drivers. Is there anything but Access that really needs the bridge...? Use the jTds driver (google for it). Or just last week Microsoft beta'ed a new JDBC driver for MSSQL; no idea how good it is. Some smalltalk on that: http://www.theserverside.com/news/thread.tss?thread_id=35063
    Second, what error do you get?
    If it is "connection refused", here is my standard first aid check list:
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • About JDBC CALL STORE PROCEDURE with out parameter is greater than 4000

    Hi Guys,
    I have a problem call store procedure with a large string.
    as i know varchar2 can contain 32767 characters in pl/sql .
    But when i used varchar2 as a out parameter in a store procedure, if the out parameter is greater than 4000 characters , it always give me error message as 'the buffer is too small'.
    why it happened?
    I read some article that says i need configure a property in data-source.xml , and jdbc 10g driver already solved this problem, but i used jdev 10.1.3.2 ,the driver should be fine.
    How can i solve this problem?
    Thanks in advance,
    AppCat

    Object is Foundation, Execute Script
    This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import java.sql.*;
    PreparedStatement stmt = null;
    Connection conn = null;
    ResultSet rs = null;
    try {
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
    conn = ds.getConnection();
    stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
    stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
    rs = stmt.executeQuery();
    rs.next();
    patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
    } finally {
    try {
    rs.close();
    } catch (Exception rse) {}
    try {
    stmt.close();
    } catch (Exception sse) {}
    try {
    conn.close();
    } catch (Exception cse) {}

  • Question about JDBC in BlazeDS?

    stupid question: is their a JDBC driver already installed with BlazeDS? I am currently installing BlazeDS in tomcat. Do i need to install the connector j separately, or does this come with BlazeDS? thanks

    The turnkey install ships with samples that use the HyperSQL database. The JDBC driver for this databse can be found in tomcat\webapps\samples\WEB-INF\lib\hsqldb.jar. If you want to connect to a different database then you'll need to download and deploy the JDBC driver for that database.
    The non-turnkey install does not contain a JDBC driver.

Maybe you are looking for

  • Reversal of a goods receipt for PO in EUR is differently valuated.

    Hi, Do you know how can i solve such problem: The return delivery or reversal of a goods receipt for a purchase order, scheduling agreement, or production order is valuated differently than the original goods receipt becouse system takes exchane rate

  • How To Switch Off Update Alerts

    I personally do not want many of the changes offered to be made, especially as the OVI version keeps disconnecting my internet... and features I have no care for taking up the memory space on my mobile. There's a few features I really want which woul

  • Wireless Keyboard and Magic Mouse (Bluetooth) Problems

    Hi folks, I recently got a new Mac Mini, wireless keyboard (Apple) and Magic Mouse. During high LAN activity, the keyboard and Magic Mouse will often lose connection and will have trouble re-connecting even when LAN activity goes back to basal levels

  • E4500 - Can't see networked PC's

    Since the upgrade by Cisco I can only see Win7 PC's on the network. I can not see the USB drive attached to the E4500, nor can I see my Media server which is Linux based nor any Win XP computuers. Solved! Go to Solution.

  • Dateiinfo (nicht PDF-Eigenschaften) mittels VB auslesen

    In meiner Firma ist ein kleines Tool im Einsatz, welches die Dateiinfos von (Office)Dateien ausliest und in ein Excel-Sheet einträgt. Gibt es eine Möglichkeit das auch mit der Dateiinfo einer PDF-Datei zu machen? Die Infos aus den PDF-Eigenschaften h