Closed
Get DB Connection in java
Hi all,
I'm using CopyManager API to export large data to excel but I don't know how to get connection from an existing Database instance.
My sample code bellow
FileOutputStream fileOutputStream = null;
Connection conn = null;
java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@dev.mycompany.com:8091:DEV", "username", "password"); // I do not want to hardcode the password
CopyManager copyManager = new CopyManager((BaseConnection) conn);
fileOutputStream = new FileOutputStream(filePath);
copyManager.copyOut("COPY " + tableOrQuery + " TO STDOUT", fileOutputStream);
***Edited by Moderator: Pooja Gadige to add platform capability tag***