old jdbc driver generates ORA-28040

I read on note 401934.1 that Oracle 10gR2 jdbc clients are still supported with Oracle 12c. I have an application using an oracle10gr2 jdbc, and connection to 12c generates ORA-28040. Connection to 11gR2 works like a charm. O12.java import java.util.Properties; import java.sql.*; public class O12 {   public static void main(String argv[]) throws       SQLException {     Properties […]

TCPS and SSLv2Hello

Thanks to platform independence, the same java code work on different platforms. import java.util.Properties; import java.security.Security; import java.sql.*; import javax.net.ssl.*; public class KeyStore {   public static void main(String argv[])       throws SQLException {     String url="jdbc:oracle:thin:@(DESCRIPTION="+       "(ADDRESS=(PROTOCOL=TCPS)(Host=SRV01)("+       "Port=1521))(CONNECT_DATA=(SID=DB01)))";     Properties props = new Properties();     props.setProperty("user", "scott");     props.setProperty("password", "tiger");     props.setProperty("javax.net.ssl.trustStore",       "keystore.jks");     props.setProperty(       "javax.net.ssl.trustStoreType","JKS");     props.setProperty(       "javax.net.ssl.trustStorePassword","***");     DriverManager.registerDriver(       new oracle.jdbc.OracleDriver());     Connection […]

multiconsumer Queue with an Oracle Type from Java

You have a multi consumer queue with a user defined type CREATE TYPE topic_message AS OBJECT(Subject VARCHAR2(30),Text VARCHAR2(80)) / BEGIN   dbms_aqadm.create_queue_table(     'topic_queue_table',     'topic_message',     Multiple_consumers=>TRUE);   dbms_aqadm.create_queue(     'toy_topic',     'topic_queue_table');   dbms_aqadm.start_queue(     'toy_topic'); END; / You create the corresponding java class with JPublisher (check the documentation of Database JPublisher User’s Guide 12c Release 1 (12.1) from which I took […]

Advanced Queuing hello world

First for those who are looking for the difference between Queuing, Advanced Queuing (AQ) and Streams Advanced Queuing, there is none. There is no Beginner Queuing and Advanced Queuing was renamed to Streams advanced queuing when streams was popular and renamed back to Advanced Queuing was streams was deprecated. I am the provider, I give […]

TNSNAMES and Active Directory

It is highly probable you already have MS AD in your company. Probably you use a local tnsnames.ora. Apart from setting a Oracle Internet Directory or Oracle Virtual Directory, there is one more option that you may want to consider : AD. Ok, here is a bit of a road map : – Schema Extension […]

How to unload blob from the database?

There is more than one post on how to unload blob from the database, mostly in plsql with utl_file.put_raw (see note 330146.1) and with java with FileOutputStream (see note 247546.1) Unfortunately both are terribly slow due to the 32k limitation of put_raw in utl_file and due to a low “optimum buffer size” retrieved by myBlob.getBufferSize(), […]

jdbc ssl

I already wrote about jdbc hello world and listener with tcps. Let’s combine both technologies ! TCPS.java import java.util.Properties; import java.security.Security; import java.sql.*; import javax.net.ssl.*; public class TCPS {   public static void main(String argv[]) throws SQLException {     String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(Host=dbsrv001)(Port=12345))(CONNECT_DATA=(SID=DB01)))";     Properties props = new Properties();     props.setProperty("user", "scott");     props.setProperty("password", "tiger");     props.setProperty("javax.net.ssl.trustStore","cwallet.sso");     props.setProperty("javax.net.ssl.trustStoreType","SSO");     Security.addProvider(new oracle.security.pki.OraclePKIProvider());     DriverManager.registerDriver(new […]

jdbc hello world

I am in a java mood today, let’s check how to print hello world with jdbc 🙂 import java.sql.*; public class HelloWorld {   public  static void main(String[] args) throws SQLException {     DriverManager.registerDriver(new oracle.jdbc.OracleDriver());     ResultSet res = DriverManager.       getConnection("jdbc:oracle:thin:@srv1:1521:DB01", "scott", "tiger").       prepareCall("select 'Hello World' txt from dual").       executeQuery();     res.next();     System.out.println(res.getString("TXT"));   } } let’s compile javac -classpath $ORACLE_HOME/jdbc/lib/classes12.jar […]

Epoch

How do I get the current number of milliseconds since 1970-01-01. I still have no access to oracle.com so I created a new account to answer this question. Either you use the difference between timestamp ‘1970-01-01 00:00:00 +00:00’ and current_timestamp, or you can use java, which is more portable. YMMV create function epoch return number […]

How to load BLOB in the database?

I have been asked yesterday how to read and write blobs in the database. With java : read from an input stream InputStream myBlobInputStream =   connection .     createStatement() .       executeQuery("select myBlob from t") .         getBlob(1) .           getBinaryStream(); write to an output stream OutputStream myBlobStream =   connection .     createStatement() .       executeQuery("select myBlob from t for update") […]