PL/SQL (MOSC)

MOSC Banner

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(?, ?,

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center