create or replace and compile java source named "java_demo" as
import java.io.* ;
import java.sql.*;
import oracle.jdbc.*;
public class java_demo
{
  public static long type2call()
  {
    try
    {
      int rows = 0 ;
      Connection conn = DriverManager.getConnection("jdbc:default:connection:");
      String sql = "select count(*) from emp" ;
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery(sql);
      while (rset.next())
      {
            rows = rset.getInt(1);
      }
      return rows ;
    }
    catch ( Exception e )
    {
      return -1 ;
    }
  }
  public static long type4call()
  {
    try
    {
      int rows = 0 ;
      Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger");
      String sql = "select count(*) from emp" ;
      Statement stmt = conn.createStatement();
      ResultSet rset = stmt.executeQuery(sql);
      while (rset.next())
      {
            rows = rset.getInt(1);
      }
      return rows ;
    }
    catch ( Exception e )
    {
      return -1 ;
    }
  }
  public static long workingdaydiff(java.util.Date d1, java.util.Date d2) {
    return wdnum(d2) - wdnum(d1);
  }
  private static long wdnum(java.util.Date date) {
    long l = div(date.getTime(), 1000 * 60 * 60 * 24)[0] + 3;
    long d[] = div(l, 7);
    return 5 * d[0] + Math.min(d[1], 5);
  }
  private static long[] div(long n, long d) {
    long q = n / d;
    long r = n % d;
    if (r < 0) {
        q--;
        r += d;
    }
    return new long[] { q, r };
  }
}
/
