alter session set current_schema problem with jdbc ?

Hello experts,
Is there a issue executing 'alter session set current_schema jdbc=STUFF'
to oracle thru JDBC.
It executes but does not alter the schema for subsequent queries from within the same connection.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alter session set current_schema =scott
select count(*) from emp;
WaponiAuthor Commented:
My typo
 alter session set current_schema=STUFF
executes but does not alter the schema for subsequent queries from within the same connection.
it works
java / ojdbc6.jar v12.0.1.0

package jdbc;

import java.sql.*;

public class OracleSetSchema {

      public static void main(String args[]) {
            try {
                  // url="jdbc:oracle:thin:@redhat:1521:orcl";
                  String ls_sql = "select count(*) from dd";
                  // select table_name from dba_tables where owner=:b0 order by
                  // table_name
                  String ls_sql_alter = "alter session set current_schema =ggtest";

                  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                  // new;
                  // new;

                  Connection conn = null;
                  try {
                        conn = DriverManager
                          "jdbc:oracle:thin:@", "scott",

                        Statement stmt = conn.createStatement();

                        int rt = stmt.executeUpdate(ls_sql_alter);
                        System.out.println("alter result =" + rt);

                        Statement stmt2 = conn.createStatement();
                        ResultSet rs2 = stmt2.executeQuery(ls_sql);
                        // count
                        System.out.println(ls_sql + "=" + rs2.getLong(1));


                  } catch (SQLException e) {
                  } finally {
                        // finally
                        // {
                        // try { stmt.close(); }
                        // catch( Exception e ) {}
                        // try { con.close(); }
                        // catch( Exception e ) {}
                        // } // end finally clause
                        if (conn != null) {

            } catch (Exception ee) {
You might be grabbing (different) connection before executing any query.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WaponiAuthor Commented:
I was getting a new con inbetween the alter and the statement.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.