Name: sgC58550 Date: 03/27/97
The close (from DriverManager.getConnection(url,usr,pwd)) messes up the System.out.println
outside the method by preventing display of more than 2 lines.
// File named "contst.java"
// The problem line is "con.close" but it might have something
// to do with other stuff, such as "stmt.close();"
import java.net.URL;
import java.sql.*;
import sun.jdbc.odbc.JdbcOdbcDriver;
class contst {
String[] tstarr = new String[100];
private static String url = "jdbc:odbc:poll";
public String[] justconnect () {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt = con.createStatement();
for(int i=0; i<10; i++) { tstarr[i] = "component#" + i; }
stmt.close();
con.close(); // <-- This is the problem line
}The
catch( Exception e) {
System.out.println( e.getMessage());
e.printStackTrace();
}
return tstarr;
}
}
----------------------------------------------------------------
//File named "contstmain.java"
import contst;
class contstmain {
//***********************************************************************
// the MAIN part
//
public static void main(String argv[]) {
contst X = new contst();
try {
String[] tstarr = new String[100];
tstarr = X.justconnect();
for(int i=0; i<10; i++) { System.out.println(tstarr[i]); }
// The line above is where it prints only 2 lines at most
}
catch( Exception e) {
System.out.println( e.getMessage());
e.printStackTrace();
}
}
}
----------------------------------------------------------------
company - Espectra Media, Inc. , email - ###@###.###
======================================================================