Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2e3c56a

Browse files
committed
Cleanup of backpatch of jdbc2 improvements to jdbc1:
Here's what I came up with. The biggest difference api between JDK1.x and later versions is the support for collections. The problem was with the Vector class; in jdk1.x there is no method called add, so I changed the calls to addElement. Also no addAll, so I rewrote the method slightly to not require addAll. While reviewing this I notices some System.out.println statements that weren't commented out. So I commented them out in both versions. The upshot of all of this is that I have clean compile, but no idea if the code works ;( Dave Cramer
1 parent 1ef5c99 commit 2e3c56a

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,20 +2186,21 @@ public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String t
21862186
);
21872187
}
21882188

2189-
private Vector importLoop(java.sql.ResultSet keyRelation) throws SQLException {
2189+
private void importLoop(Vector tuples, java.sql.ResultSet keyRelation) throws SQLException
2190+
{
21902191
String s,s2;
21912192
String origTable=null, primTable=new String(""), schema;
21922193
int i;
2193-
Vector v;
2194+
Vector v=new Vector();
21942195

21952196
s=keyRelation.getString(1);
21962197
s2=s;
2197-
System.out.println(s);
2198-
v=new Vector();
2198+
//System.out.println(s);
2199+
21992200
for (i=0;;i++) {
22002201
s=s.substring(s.indexOf("\\000")+4);
22012202
if (s.compareTo("")==0) {
2202-
System.out.println();
2203+
//System.out.println();
22032204
break;
22042205
}
22052206
s2=s.substring(0,s.indexOf("\\000"));
@@ -2214,15 +2215,15 @@ private Vector importLoop(java.sql.ResultSet keyRelation) throws SQLException {
22142215
schema=s2;
22152216
break;
22162217
default:
2217-
v.add(s2);
2218+
v.addElement(s2);
22182219
}
22192220
}
22202221

22212222
java.sql.ResultSet rstmp=connection.ExecSQL("select * from "+origTable+" where 1=0");
22222223
java.sql.ResultSetMetaData origCols=rstmp.getMetaData();
22232224

22242225
String stmp;
2225-
Vector tuples=new Vector();
2226+
// Vector tuples=new Vector();
22262227
byte tuple[][];
22272228

22282229
// the foreign keys are only on even positions in the Vector.
@@ -2248,17 +2249,17 @@ private Vector importLoop(java.sql.ResultSet keyRelation) throws SQLException {
22482249
//KEY_SEQ
22492250
tuple[8]=Integer.toString(j).getBytes();
22502251

2251-
tuples.add(tuple);
2252+
tuples.addElement(tuple);
22522253

2253-
System.out.println(origCols.getColumnName(j)+
2254-
": "+j+" -> "+primTable+": "+
2255-
(String)v.elementAt(i+1));
2254+
//System.out.println(origCols.getColumnName(j)+
2255+
//": "+j+" -> "+primTable+": "+
2256+
//(String)v.elementAt(i+1));
22562257
break;
22572258
}
22582259
}
22592260
}
22602261

2261-
return tuples;
2262+
//return tuples;
22622263
}
22632264

22642265

@@ -2342,7 +2343,7 @@ public java.sql.ResultSet getImportedKeys(String catalog, String schema, String
23422343
Vector tuples=new Vector();
23432344

23442345
while (rs.next()) {
2345-
tuples.addAll(importLoop(rs));
2346+
importLoop(tuples,rs);
23462347
}
23472348

23482349
rsret=new ResultSet(connection, f, tuples, "OK", 1);

src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,12 +2194,12 @@ private Vector importLoop(java.sql.ResultSet keyRelation) throws SQLException {
21942194

21952195
s=keyRelation.getString(1);
21962196
s2=s;
2197-
System.out.println(s);
2197+
// System.out.println(s);
21982198
v=new Vector();
21992199
for (i=0;;i++) {
22002200
s=s.substring(s.indexOf("\\000")+4);
22012201
if (s.compareTo("")==0) {
2202-
System.out.println();
2202+
//System.out.println();
22032203
break;
22042204
}
22052205
s2=s.substring(0,s.indexOf("\\000"));
@@ -2249,10 +2249,11 @@ private Vector importLoop(java.sql.ResultSet keyRelation) throws SQLException {
22492249
tuple[8]=Integer.toString(j).getBytes();
22502250

22512251
tuples.add(tuple);
2252-
2252+
/*
22532253
System.out.println(origCols.getColumnName(j)+
22542254
": "+j+" -> "+primTable+": "+
22552255
(String)v.elementAt(i+1));
2256+
*/
22562257
break;
22572258
}
22582259
}

0 commit comments

Comments
 (0)