Question

28
Views
Lanh NguyenTrung (LanhNT)
Fpt Software Joint-Stock Company
Pega Tech Leader
Fpt Software Joint-Stock Company
JP
LanhNT Member since 2018 9 posts
Fpt Software Joint-Stock Company
Posted: December 15, 2020
Last activity: December 16, 2020
Posted: 15 Dec 2020 20:58 EST
Last activity: 16 Dec 2020 3:37 EST

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***
Pega Platform 8.4 User Experience Data Integration Other Industry System Architect