Permalink
Browse files

Basic query cancellation and query timeout added.Makefile updated and…

… META.json corrected
  • Loading branch information...
1 parent 90b5375 commit 930a28423558a1bcc229869a0f4accc1bd14dffe @atris committed Jul 2, 2012
Showing with 227 additions and 44 deletions.
  1. +46 −17 JDBCClasses/JDBCUtils.java
  2. +3 −3 META.json
  3. +1 −4 Makefile
  4. +76 −0 README
  5. +101 −20 jdbc_fdw.c
@@ -6,11 +6,11 @@
private Connection conn;
private int NumberOfColumns;
private int NumberOfRows;
+ private Statement sql;
private String[] Iterate;
-public int
+public void
Initialize(String[] ar1) throws IOException
-{
- Statement sql;
+{
DatabaseMetaData dbmd;
ResultSetMetaData r1;
String url = ar1[2];
@@ -29,17 +29,32 @@
System.out.println("Connection to "+dbmd.getDatabaseProductName()+" "+dbmd.getDatabaseProductVersion()+" successful.\n");
sql = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ try
+ {
+ if(ar1[5] == null)
+ {
+ sql.setQueryTimeout(5);
+ }
+ else
+ {
+ sql.setQueryTimeout(Integer.parseInt(ar1[5]));
+ }
+
+ }catch(Exception a)
+ {
+ System.out.println("Query timeout shall not work");
+ }
+
rs = sql.executeQuery(ar1[0]);
r1=rs.getMetaData();
NumberOfColumns=r1.getColumnCount();
Iterate=new String[NumberOfColumns];
- } catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
}
-return NumberOfColumns;
}
public String[]
ReturnResultSet()
@@ -48,23 +63,22 @@
try
{
- if(rs.next())
+ if(rs.next())
+ {
+ for(i=1;i<=NumberOfColumns;i++)
{
- for(i=1;i<=NumberOfColumns;i++)
- {
- Iterate[(i-1)]=rs.getString(i);
- }
-
- ++NumberOfRows;
+ Iterate[(i-1)]=rs.getString(i);
+ }
- return Iterate;
+ ++NumberOfRows;
- }
+ return Iterate;
+ }
- }catch (Exception e)
- {
+ }catch (Exception e)
+ {
e.printStackTrace();
- }
+ }
return null;
}
@@ -80,4 +94,19 @@
e.printStackTrace();
}
}
+public void
+Cancel()
+{
+System.out.println("\n In cancel");
+ try
+ {
+ sql.cancel();
+ rs.close();
+ conn.close();
+
+ }catch(Exception a)
+ {
+ a.printStackTrace();
+ }
+}
}
View
@@ -24,11 +24,11 @@
},
"resources": {
"bugtracker": {jdbc
- "web": "https://github.com/dpage/jdbc_fdw/issues"
+ "web": "https://github.com/atris/JDBC_FDW/issues"
},
"repository": {
- "url": "git://github.com/dpage/jdbc_fdw.git",
- "web": "http://github.com/dpage/jdbc_fdw/",
+ "url": "https://github.com/atris/JDBC_FDW.git",
+ "web": "https://github.com/atris/JDBC_FDW",
"type": "git"
}
},
View
@@ -23,10 +23,7 @@ REGRESS = jdbc_fdw
JDBC_CONFIG = jdbc_config
-export CFLAGS="$CFLAGS -ljvm"
-export CXXFLAGS="$CXXFLAGS -ljvm"
-
-
+SHLIB_LINK= -ljvm
ifdef USE_PGXS
PG_CONFIG = pg_config
View
@@ -1,3 +1,79 @@
IMPORTANT:Please note that,at the moment,for using jdbc_fdw,the user will have to manually set the classpaths:first,to JDBCUtils.class and second,to the JDBC driver which is being used for connecting and fetching data from the foreign database.
+Installing
+----------
+
Please place the JDBC_FDW folder in the /contrib directory before running make install.
+
+The steps for installing jdbc_fdw are:
+
+1)Ensure that JDK is correctly installed and its path is exported correctly.
+2)Run make install(You may have to change to root before running it).
+3)Ensure that make install completes correctly(without warnings or errors).
+
+Usage
+-----
+
+The following parameters can be set on a JDBC foreign server:
+
+drivername: The name of the JDBC driver e.g.(org.postgresql.Driver).
+ Note that drivername has to be specified for jdbc_fdw
+ to work i.e. it is compulsory.
+
+url: The JDBC URL that shall be used to connect to the foreign database.
+ Note that URL has to be specified for jdbc_fdw
+ to work i.e. it is compulsory.
+
+The following parameter can be set on a JDBC foreign table:
+
+query: An SQL query to define the data set on the JDBC server.
+
+table: The name of a table (quoted and qualified as required)
+ on the foreign database table.
+
+The following parameter can be set on a user mapping for a JDBC
+foreign server:
+
+username: The username to use when connecting to foreign database.
+ Default <none>
+
+password: The password to authenticate to the foreign database with.
+ Default: <none>
+
+Example
+-------
+
+-- Install the extension
+CREATE EXTENSION jdbc_fdw;
+
+-- Create the foreign server, a pointer to the JDBC server.
+CREATE SERVER jdbc_serv3
+ FOREIGN DATA WRAPPER jdbc_fdw
+ OPTIONS(drivername 'org.postgresql.Driver',url 'jdbc:postgresql:gitc');
+
+-- Create one or more foreign tables on the JDBC server.
+CREATE FOREIGN TABLE test12(a text,b text,c text)
+ SERVER jdbc_serv3
+ OPTIONS(query 'SELECT * FROM test11');
+
+-- Create a user mapping to tell the FDW the username/password to
+-- use to connect to foreign database. This could be done on a per-
+-- role basis.
+CREATE USER MAPPING FOR gitc
+ SERVER jdbc_serv3
+ OPTIONS(username 'gitc',password '');
+
+Features
+--------
+
+1)jdbc_fdw can connect and fetch data to PostgreSQL from any data source that supports JDBC.
+2)Basic query cancellation is supported.
+
+--
+Atri Sharma
+atri.jiit@gmail.com
+
+
+
+
+
Oops, something went wrong. Retry.

0 comments on commit 930a284

Please sign in to comment.