JDBC error when using Java stored procedure
Using Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production in Windows 10 I am trying to use the following simple Java stored procedure to obtain a list of files from a directory:
import java.io.*;
import java.sql.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class ChpAIXM51DirList{
public static void getList(String directory)
throws SQLException {
File path = new File( directory );
String[] list = path.list();
String element;
String sql;
PreparedStatement pstmt;
Connection conn = DriverManager.getConnection("jdbc:default:connection:");
for(int i = 0; i < list.length; i++){
element = list[i];
String fpath=directory+File.separator+list[i];
File f = new File(fpath);
long len;
Date date;
String ftype;
String sqldate;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (f.isFile()) {
len = f.length();
date = new Date(f.lastModified());
sqldate = df.format(date) ;
ftype = "F";
sql = "INSERT INTO chp_aixm51_dir_list (file_name, file_length, file_type, file_modified) VALUES(?, ?, 0