Re: PB: JDBC Connection
From: DriftWood <drift_wood_at_my-deja.com>
Date: Mon, 22 Jan 2001 20:27:50 GMT
Message-ID: <94i53q$6c0$1_at_nnrp1.deja.com>
public void JDBCEX () {
}
}
}
Date: Mon, 22 Jan 2001 20:27:50 GMT
Message-ID: <94i53q$6c0$1_at_nnrp1.deja.com>
[Quoted] Try using the OLite JDBC driver rather than the ODBC bridge:
import java.sql.*;
public class JDBCEX {
/**
* Constructor.
*/
public void JDBCEX () {
}
public static void main(String args[]) {
Connection conn = null;
Statement stmt = null;
ResultSet retset = null;
try {
Class.forName("oracle.pol.poljdbc.POLJDBCDriver");
conn = DriverManager.getConnection
("jdbc:Polite:POlite", "SYSTEM", "My-password");
}
catch (Exception e) {
System.out.println("An error has occurred.");
System.out.println("Please check your CLASSPATH variable and
make sure that the database is not encrypted");
System.out.println(e);
System.exit(0);
}
/* create a statment */
try {
stmt = conn.createStatement();
}
catch (SQLException e)
{
System.out.println("conn.createStatement failed: " + e
+ "\n");
System.exit(0);
}
/* retrive data from database */
try {
System.out.println(" \n------------ PRODUCT table ------
\n");
retset = stmt.executeQuery("SELECT * FROM PRODUCT");
while(retset.next()) {
int getValueInt = retset.getInt(1);
String getValueStr1 = retset.getString(2);
String getValueStr2 = retset.getString(3);
System.out.println("\t\t" + getValueInt +
"\t\t" + getValueStr1 +
"\t\t" + getValueStr2 + "\n");
}
}
catch (SQLException e) {
[Quoted] System.out.println("Error occurred...");
while(e != null) {
System.out.println(e.getMessage());
e = e.getNextException();
}
}
}
}
-- -cheers DW -------------------------------------------------------------------- "It is a kind of good deed to say well; and yet words are not deeds. -William Shakespeare" Sent via Deja.com http://www.deja.com/Received on Mon Jan 22 2001 - 21:27:50 CET
