Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff246d7

Browse files
committed
Bring in Adrian's JDBC driver as an interface
1 parentfd86ae1 commitff246d7

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+
importjava.io.*;
2+
importjava.lang.*;
3+
importjava.sql.*;
4+
5+
classJDBC_Test
6+
{
7+
publicJDBC_Test()
8+
{
9+
}
10+
11+
publicstaticvoidmain(Stringargv[])
12+
{
13+
Stringurl =newString(argv[0]);
14+
Connectiondb;
15+
Statements;
16+
ResultSetrs;
17+
18+
// Load the driver
19+
try
20+
{
21+
Class.forName("postgresql.Driver");
22+
}catch (ClassNotFoundExceptione) {
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+
inti =0;
45+
while (rs.next())
46+
{
47+
inta =rs.getInt("a");
48+
intb =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 (SQLExceptione) {
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+
packagepostgresql;
2+
3+
importjava.math.*;
4+
importjava.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+
publicclassCallableStatementimplementsjava.sql.CallableStatement
40+
{
41+
publicvoidregisterOutParameter (intparamterIndex,intsqlType)throwsSQLException
42+
{
43+
// XXX-Not Implemented
44+
}
45+
46+
publicvoidregisterOutParameter (intparameterIndex,intsqlType,intscale)throwsSQLException
47+
{
48+
// XXX-Not Implemented
49+
}
50+
51+
publicbooleanwasNull ()throwsSQLException
52+
{
53+
// XXX-Not Implemented
54+
}
55+
56+
publicStringgetString (intparameterIndex)throwsSQLException
57+
{
58+
// XXX-Not Implemented
59+
}
60+
61+
publicbooleangetBoolean (intparameterIndex)throwsSQLException
62+
{
63+
// XXX-Not Implemented
64+
}
65+
66+
publicbytegetByte (intparameterIndex)throwsSQLException
67+
{
68+
// XXX-Not Implemented
69+
}
70+
71+
publicshortgetShort (intparameterIndex)throwsSQLException
72+
{
73+
// XXX-Not Implemented
74+
}
75+
76+
publicintgetInt (intparameterIndex)throwsSQLException
77+
{
78+
// XXX-Not Implemented
79+
}
80+
81+
publiclonggetLong (intparameterIndex)throwsSQLException
82+
{
83+
// XXX-Not Implemented
84+
}
85+
86+
publicfloatgetFloat (intparameterIndex)throwsSQLException
87+
{
88+
// XXX-Not Implemented
89+
}
90+
91+
publicdoublegetDouble (intparameterIndex)throwsSQLException
92+
{
93+
// XXX-Not Implemented
94+
}
95+
96+
publicBigDecimalgetBigDecimal (intparameterIndex,intscale)throwsSQLException
97+
{
98+
// XXX-Not Implemented
99+
}
100+
101+
publicbyte[]getBytes (intparameterIndex)throwsSQLException
102+
{
103+
// XXX-Not Implemented
104+
}
105+
106+
publicDategetDate (intparameterIndex)throwsSQLException
107+
{
108+
// XXX-Not Implemented
109+
}
110+
111+
publicTimegetTime (intparameterIndex)throwsSQLException
112+
{
113+
// XXX-Not Implemented
114+
}
115+
116+
publicTimestampgetTimestamp (intparameterIndex)throwsSQLException
117+
{
118+
// XXX-Not Implemented
119+
}
120+
121+
publicObjectgetObject (intparameterIndex)throwsSQLException
122+
{
123+
// XXX-Not Implemented
124+
}
125+
126+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp