Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Java - JDBC Thin to Oracle

Avatar of tnowacoski
tnowacoski asked on
Oracle DatabaseJava
21 Comments1 Solution4647 ViewsLast Modified:
I found a simple Java program that connects to an Oracle database and returns the result of a simple select.  When I execute this the only console output I get is...What am I doing wrong?:

<Console>
testing oracle-character-set-1 against <abc>
    PASSED LOSSY
testing oracle-character-set-1 against <ab?c>
    PASSED LOSSY
testing oracle-character-set-1 against <XYZ>
    PASSED LOSSY
testing oracle-character-set-1 against <longlonglonglong...>
    PASSED LOSSY
testing oracle-character-set-31 against <abc>
    PASSED LOSSY
testing oracle-character-set-31 against <ab?c>
    PASSED LOSSY
testing oracle-character-set-31 against <XYZ>
    PASSED LOSSY
testing oracle-character-set-31 against <longlonglonglong...>
    PASSED LOSSY
testing oracle-character-set-870 against <abc>
    PASSED
testing oracle-character-set-870 against <ab?c>
    PASSED
testing oracle-character-set-870 against <XYZ>
    PASSED
testing oracle-character-set-870 against <longlonglonglong...>
    PASSED
testing oracle-character-set-871 against <abc>
    PASSED
testing oracle-character-set-871 against <ab?c>
    PASSED
testing oracle-character-set-871 against <XYZ>
    PASSED
testing oracle-character-set-871 against <longlonglonglong...>
    PASSED


<IDE>
 Eclipse 3.5

<External References>
ojdbc6.jar
<CODE>

package en.cmi.jdbccheckup;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import oracle.jdbc.OracleDriver;

public class TestOra {
    public TestOra() {
        System.setProperty("oracle.net.tns_admin","$ORACLE_HOME\\network\\admin");
    }

    public void doit () throws SQLException {
        String usr = "IFSAPP";
        String pwd = "*****"; //intentionally blanked
        String url = "jdbc:oracle:thin:@IFSTest";

        DriverManager.registerDriver(new OracleDriver());
        Connection conn = DriverManager.getConnection(url,usr,pwd);

        String sql = "select count(*) from customer_order_tab;" ;
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
             System.out.println("results: " + rs.getString(1));
        conn.close();
    }

    public static void main(String[] args){
        TestOra test = new TestOra();
        try {
            test.doit();
            System.out.println("Done..");
        }
        catch (SQLException e) {
              System.out.println("Error");
            e.printStackTrace();
        }
    }
}
ASKER CERTIFIED SOLUTION
Avatar of tnowacoski
tnowacoski

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 21 Comments.
See Answers