title: How can I set a connection property?
body: <p>I can connect fine to an Oracle 11.2 database using JDBC driver and the following Java code:</p>
  
  <pre><code>  import java.sql.*;
    import javax.sql.DataSource;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.OracleTypes;
    ...
    Connection conn=null;
  
    // connect to database
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup("jdbc/myPool");
    conn = ds.getConnection();
  </code></pre>
  
  <p>But now I need to set the option <code>SetFloatAndDoubleUseBinary</code> to true. See page 4-16 here</p>
  
  <p><a href="http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf" rel="nofollow">http://docs.oracle.com/cd/E14072_01/java.112/e10589.pdf</a></p>
  
  <p>So I try to follow examples from here:</p>
  
  <p><a href="http://docs.oracle.com/cd/E11882_01/java.112/e16548/urls.htm" rel="nofollow">http://docs.oracle.com/cd/E11882_01/java.112/e16548/urls.htm</a></p>
  
  <p>and I modify the code as:</p>
  
  <pre><code>  import java.sql.*;
    import java.util.Properties;
    import javax.sql.DataSource;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.OracleTypes;
    ...
    Connection conn=null;
  
    // set connection properties
    Properties info = new java.util.Properties();
    info.put ("SetFloatAndDoubleUseBinary","true");
  
    // connect to database
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup("jdbc/myPool");
    conn = ds.getConnection(info);
  </code></pre>
  
  <p>and I'm getting the following compile error:</p>
  
  <pre><code>myClass.java:1145: cannot find symbol
  symbol  : method getConnection(java.util.Properties)
  location: interface javax.sql.DataSource
            conn = ds.getConnection(info);
                     ^
  </code></pre>
  
  <p>Anyone know how I can properly set <code>SetFloatAndDoubleUseBinary</code> here?</p>
  
  <p>UPDATE 1</p>
  
  <p>Changing to:</p>
  
  <pre><code>  import java.sql.*;
    import java.util.Properties;
    import javax.sql.DataSource;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.OracleTypes;
    import oracle.jdbc.*;       // NEW
    import oracle.jdbc.pool.*;  // NEW
    ...
    Connection conn=null;
  
    // set connection properties
    Properties info = new java.util.Properties();
    info.put ("SetFloatAndDoubleUseBinary","true");
  
    // connect to database
    Context context = new InitialContext();
    DataSource ds = (DataSource)context.lookup("jdbc/myPool");
    ((OracleDataSource)ds).setConnectionProperties(info); // NEW
    conn = ds.getConnection();                    // NEW
  </code></pre>
  
  <p>gives the following run time error:</p>
  
  <p><code>stack trace: java.lang.ClassCastException: com.sun.gjc.spi.jdbc40.DataSource40 cannot be cast to oracle.jdbc.pool.OracleDataSource</code></p>