Skip to content

Commit ff246d7

Browse files
committed
Bring in Adrian's JDBC driver as an interface
1 parent fd86ae1 commit ff246d7

File tree

11 files changed

+5097
-0
lines changed

11 files changed

+5097
-0
lines changed

src/interfaces/jdbc/JDBC_Test.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import java.io.*;
2+
import java.lang.*;
3+
import java.sql.*;
4+
5+
class JDBC_Test
6+
{
7+
public JDBC_Test()
8+
{
9+
}
10+
11+
public static void main(String argv[])
12+
{
13+
String url = new String(argv[0]);
14+
Connection db;
15+
Statement s;
16+
ResultSet rs;
17+
18+
// Load the driver
19+
try
20+
{
21+
Class.forName("postgresql.Driver");
22+
} catch (ClassNotFoundException e) {
23+
System.err.println("Exception: " + e.toString());
24+
}
25+
26+
// Lets do a few things -- it doesn't do everything, but
27+
// it tests out basic functionality
28+
try
29+
{
30+
System.out.println("Connecting to Database URL = " + url);
31+
db = DriverManager.getConnection(url, "adrian", "");
32+
System.out.println("Connected...Now creating a statement");
33+
s = db.createStatement();
34+
System.out.println("Ok...now we will create a table");
35+
s.executeUpdate("create table test (a int2, b int2)");
36+
System.out.println("Now we will insert some columns");
37+
s.executeUpdate("insert into test values (1, 1)");
38+
s.executeUpdate("insert into test values (2, 1)");
39+
s.executeUpdate("insert into test values (3, 1)");
40+
System.out.println("Inserted some data");
41+
System.out.println("Now lets try a select");
42+
rs = s.executeQuery("select a, b from test");
43+
System.out.println("Back from the select...the following are results");
44+
int i = 0;
45+
while (rs.next())
46+
{
47+
int a = rs.getInt("a");
48+
int b = rs.getInt("b");
49+
System.out.println("row " + i + " " + a + " " + b);
50+
i++;
51+
}
52+
System.out.println("Ok...dropping the table");
53+
s.executeUpdate("drop table test");
54+
System.out.println("Now closing the connection");
55+
s.close();
56+
db.close();
57+
} catch (SQLException e) {
58+
System.out.println("Exception: " + e.toString());
59+
}
60+
}
61+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package postgresql;
2+
3+
import java.math.*;
4+
import java.sql.*;
5+
6+
/**
7+
* @version 1.0 15-APR-1997
8+
* @author <A HREF="mailto:adrian@hottub.org">Adrian Hall</A>
9+
*
10+
* CallableStatement is used to execute SQL stored procedures.
11+
*
12+
* JDBC provides a stored procedure SQL escape that allows stored procedures
13+
* to be called in a standard way for all RDBMS's. This escape syntax has
14+
* one form that includes a result parameter and one that does not. If used,
15+
* the result parameter must be generated as an OUT parameter. The other
16+
* parameters may be used for input, output or both. Parameters are refered
17+
* to sequentially, by number. The first parameter is 1.
18+
*
19+
* <PRE>
20+
* {?= call <procedure-name>[<arg1>,<arg2>, ...]}
21+
* {call <procedure-name>[<arg1>,<arg2>, ...]}
22+
* </PRE>
23+
*
24+
* IN parameters are set using the set methods inherited from
25+
* PreparedStatement. The type of all OUT parameters must be registered
26+
* prior to executing the stored procedure; their values are retrieved
27+
* after execution via the get methods provided here.
28+
*
29+
* A CallableStatement may return a ResultSet or multiple ResultSets. Multiple
30+
* ResultSets are handled using operations inherited from Statement.
31+
*
32+
* For maximum portability, a call's ResultSets and update counts should be
33+
* processed prior to getting the values of output parameters.
34+
*
35+
* @see java.sql.Connection#prepareCall
36+
* @see java.sql.ResultSet
37+
* @see java.sql.CallableStatement
38+
*/
39+
public class CallableStatement implements java.sql.CallableStatement
40+
{
41+
public void registerOutParameter (int paramterIndex, int sqlType) throws SQLException
42+
{
43+
// XXX-Not Implemented
44+
}
45+
46+
public void registerOutParameter (int parameterIndex, int sqlType, int scale) throws SQLException
47+
{
48+
// XXX-Not Implemented
49+
}
50+
51+
public boolean wasNull () throws SQLException
52+
{
53+
// XXX-Not Implemented
54+
}
55+
56+
public String getString (int parameterIndex) throws SQLException
57+
{
58+
// XXX-Not Implemented
59+
}
60+
61+
public boolean getBoolean (int parameterIndex) throws SQLException
62+
{
63+
// XXX-Not Implemented
64+
}
65+
66+
public byte getByte (int parameterIndex) throws SQLException
67+
{
68+
// XXX-Not Implemented
69+
}
70+
71+
public short getShort (int parameterIndex) throws SQLException
72+
{
73+
// XXX-Not Implemented
74+
}
75+
76+
public int getInt (int parameterIndex) throws SQLException
77+
{
78+
// XXX-Not Implemented
79+
}
80+
81+
public long getLong (int parameterIndex) throws SQLException
82+
{
83+
// XXX-Not Implemented
84+
}
85+
86+
public float getFloat (int parameterIndex) throws SQLException
87+
{
88+
// XXX-Not Implemented
89+
}
90+
91+
public double getDouble (int parameterIndex) throws SQLException
92+
{
93+
// XXX-Not Implemented
94+
}
95+
96+
public BigDecimal getBigDecimal (int parameterIndex, int scale) throws SQLException
97+
{
98+
// XXX-Not Implemented
99+
}
100+
101+
public byte[] getBytes (int parameterIndex) throws SQLException
102+
{
103+
// XXX-Not Implemented
104+
}
105+
106+
public Date getDate (int parameterIndex) throws SQLException
107+
{
108+
// XXX-Not Implemented
109+
}
110+
111+
public Time getTime (int parameterIndex) throws SQLException
112+
{
113+
// XXX-Not Implemented
114+
}
115+
116+
public Timestamp getTimestamp (int parameterIndex) throws SQLException
117+
{
118+
// XXX-Not Implemented
119+
}
120+
121+
public Object getObject (int parameterIndex) throws SQLException
122+
{
123+
// XXX-Not Implemented
124+
}
125+
126+
}

0 commit comments

Comments
 (0)