import java.sql.*;
import org.postgresql.largeobject.*;
-/**
+/*
* This example is a small application that stores and displays images
* held on a postgresql database.
*
paint(g);
}
- /**
+ /*
* Paints the image, using double buffering to prevent screen flicker
*/
public void paint(Graphics gr)
}
- /**
+ /*
* This method initialises the database by creating a table that contains
* the image names, and Large Object OID's
*/
//}
}
- /**
+ /*
* This closes the connection, and ends the application
*/
public void close()
System.exit(0);
}
- /**
+ /*
* This imports an image into the database, using a Thread to do this in the
* background.
*/
t.start();
}
- /**
+ /*
* This is an example of using a thread to import a file into a Large Object.
* It uses the Large Object extension, to write blocks of the file to the
* database.
}
}
- /**
+ /*
* This refreshes the list of available images
*/
public void refreshList()
}
}
- /**
+ /*
* This removes an image from the database
*
* Note: With postgresql, this is the only way of deleting a large object
}
}
- /**
+ /*
* This displays an image from the database.
*
* For images, this is the easiest method.
displayImage(list.getItem(((Integer)e.getItem()).intValue()));
}
- /**
+ /*
* This is the command line instructions
*/
public static void instructions()
System.err.println("Note: If you are running this for the first time on a particular database,\nyou have to select \"Initialise\" in the \"PostgreSQL\" menu.\nThis will create a table used to store image names.");
}
- /**
+ /*
* This is the application entry point
*/
public static void main(String args[])
import java.sql.*;
import java.util.*;
-/**
+/*
* Test inserting and extracting Unicode-encoded strings.
*
* Synopsis:
public class Unicode
{
- /**
+ /*
* The url for the database to connect to.
*/
private String url;
- /**
+ /*
* The user to connect as.
*/
private String user;
- /**
+ /*
* The password to connect with.
*/
private String password;
this.password = password;
}
- /**
+ /*
* Establish and return a connection to the database.
*/
private Connection getConnection() throws SQLException,
return DriverManager.getConnection(url, info);
}
- /**
+ /*
* Get string representing a block of 256 consecutive unicode characters.
* We exclude the null character, "'", and "\".
*/
return sb.toString();
}
- /**
+ /*
* Is the block a block of valid unicode values.
* d800 to db7f is the "unassigned high surrogate" range.
* db80 to dbff is the "private use" range.
return true;
}
- /**
+ /*
* Report incorrect block retrieval.
*/
private void reportRetrievalError(int blockNum, String block,
log(message);
}
- /**
+ /*
* Do the testing.
*/
public void runTest()
import java.sql.*;
import java.text.*;
-/**
+/*
*
- * $Id: basic.java,v 1.8 2001/10/25 05:59:58 momjian Exp $
+ * $Id: basic.java,v 1.9 2001/11/19 22:43:13 momjian Exp $
*
* This example tests the basic components of the JDBC driver, and shows
* how even the simplest of queries can be implemented.
//throw postgresql.Driver.notImplemented();
}
- /**
+ /*
* This drops the table (if it existed). No errors are reported.
*/
public void cleanup()
}
}
- /**
+ /*
* This performs the example
*/
public void doexample() throws SQLException
// cleanup() method.
}
- /**
+ /*
* Display some instructions on how to run the example
*/
public static void instructions()
System.exit(1);
}
- /**
+ /*
* This little lot starts the test
*/
public static void main(String args[])
import java.sql.*;
import org.postgresql.largeobject.*;
-/**
+/*
* This test attempts to create a blob in the database, then to read
* it back.
*
}
- /**
+ /*
* Now this is an extension to JDBC, unique to postgresql. Here we fetch
* an PGlobj object, which provides us with access to postgresql's
* large object api.
import java.sql.*;
import org.omg.CosNaming.*;
-/**
+/*
* This class is the frontend to our mini CORBA application.
*
* It has no GUI, just a text frontend to keep it simple.
*
- * $Id: StockClient.java,v 1.2 2001/10/25 05:59:58 momjian Exp $
+ * $Id: StockClient.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
*/
public class StockClient
{
import java.sql.*;
-/**
+/*
* This class handles the JDBC side of things. It opens a connection to
* the database, and performes queries on that database.
*
* that an object could be changed by another client, and we need to ensure that
* the returned data is live and accurate.
*
- * $Id: StockDB.java,v 1.3 2001/10/25 05:59:58 momjian Exp $
+ * $Id: StockDB.java,v 1.4 2001/11/19 22:43:13 momjian Exp $
*/
public class StockDB
{
import org.omg.CosNaming.*;
-/**
+/*
* This class implements the server side of the example.
*
- * $Id: StockDispenserImpl.java,v 1.2 2001/10/25 05:59:58 momjian Exp $
+ * $Id: StockDispenserImpl.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
*/
public class StockDispenserImpl extends stock._StockDispenserImplBase
{
}
}
- /**
+ /*
* This method, defined in stock.idl, reserves a slot in the dispenser
*/
public stock.StockItem reserveItem() throws stock.StockException
return null;
}
- /**
+ /*
* This releases a slot from the dispenser
*/
public void releaseItem(stock.StockItem item) throws stock.StockException
return ;
}
- /**
+ /*
* This class defines a slot in the dispenser
*/
class StockItemStatus
import org.omg.CosNaming.*;
-/**
+/*
* This class implements the server side of the example.
*
- * $Id: StockItemImpl.java,v 1.2 2001/10/25 05:59:58 momjian Exp $
+ * $Id: StockItemImpl.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
*/
public class StockItemImpl extends stock._StockItemImplBase
{
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It sets the item to view
}
- /**
+ /*
* This is defined in stock.idl
*
* It sets the item to view
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This is defined in stock.idl
*
* It returns the description of a Stock item
}
}
- /**
+ /*
* This returns the highest id used, hence the number of items available
*/
public int getLastID() throws stock.StockException
}
}
- /**
+ /*
* This is used by our Dispenser
*/
public String getInstanceName()
import org.omg.CosNaming.*;
-/**
+/*
* This class implements the server side of the example.
*
- * $Id: StockServer.java,v 1.2 2001/10/25 05:59:58 momjian Exp $
+ * $Id: StockServer.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
*/
public class StockServer
{
import java.sql.*;
import java.text.*;
-/**
+/*
* This example tests the various date styles that are available to postgresql.
*
* To use this example, you need a database to be in existence. This example
}
- /**
+ /*
* This drops the table (if it existed). No errors are reported.
*/
public void cleanup()
}
}
- /**
+ /*
* This initialises the database for this example
*/
public void init() throws SQLException
}
- /**
+ /*
* This performs the example
*/
public void doexample() throws SQLException
}
}
- /**
+ /*
* Display some instructions on how to run the example
*/
public static void instructions()
System.exit(1);
}
- /**
+ /*
* This little lot starts the test
*/
public static void main(String args[])
import java.sql.*;
import java.text.*;
-/**
+/*
* This example application is not really an example. It actually performs
* some tests on various methods in the DatabaseMetaData and ResultSetMetaData
* classes.
Statement st; // Our statement to run queries with
DatabaseMetaData dbmd; // This defines the structure of the database
- /**
+ /*
* These are the available tests on DatabaseMetaData
*/
public void doDatabaseMetaData() throws SQLException
}
- /**
+ /*
* These are the available tests on ResultSetMetaData
*/
public void doResultSetMetaData() throws SQLException
rs.close();
}
- /**
+ /*
* This creates some test data
*/
public void init() throws SQLException
st.executeUpdate("insert into test_c values ('nowhere particular','$10.99',1)");
}
- /**
+ /*
* This removes the test data
*/
public void cleanup() throws SQLException
cleanup();
}
- /**
+ /*
* This asks if the user requires to run a test.
*/
public boolean doTest(String s)
return c == 'y' || c == 'Y';
}
- /**
+ /*
* This displays a result set.
* Note: it closes the result once complete.
*/
rs.close();
}
- /**
+ /*
* This process / commands (for now just /d)
*/
public void processSlashCommand(String line) throws SQLException
private static final String usrSequences[] = {"SEQUENCE"};
private static final String sysTables[] = {"SYSTEM TABLE", "SYSTEM INDEX"};
- /**
+ /*
* Display some instructions on how to run the example
*/
public static void instructions()
System.exit(1);
}
- /**
+ /*
* This little lot starts the test
*/
public static void main(String args[])
import java.sql.*;
import java.text.*;
-/**
+/*
* This example application demonstrates some of the drivers other features
* by implementing a simple psql replacement in Java.
*
}
- /**
+ /*
* This processes a statement
*/
public void processLine(String line) throws SQLException
}
}
- /**
+ /*
* This displays a result set.
* Note: it closes the result once complete.
*/
rs.close();
}
- /**
+ /*
* This process / commands (for now just /d)
*/
public void processSlashCommand(String line) throws SQLException
private static final String usrSequences[] = {"SEQUENCE"};
private static final String sysTables[] = {"SYSTEM TABLE", "SYSTEM INDEX"};
- /**
+ /*
* Display some instructions on how to run the example
*/
public static void instructions()
System.exit(1);
}
- /**
+ /*
* This little lot starts the test
*/
public static void main(String args[])
// rare in user code, but we use the LargeObject API in this test
import org.postgresql.largeobject.*;
-/**
+/*
* This example tests the thread safety of the driver.
*
* It does this by performing several queries, in different threads. Each
}
- /**
+ /*
* This drops the table (if it existed). No errors are reported.
*/
public void cleanup()
}
}
- /**
+ /*
* This performs the example
*/
public void doexample() throws SQLException
}
}
- /**
+ /*
* Display some instructions on how to run the example
*/
public static void instructions()
System.exit(1);
}
- /**
+ /*
* This little lot starts the test
*/
public static void main(String args[])
package utils;
-/**
+/*
* This little app checks to see what version of JVM is being used.
* It does this by checking first the java.vm.version property, and
* if that fails, it looks for certain classes that should be present.
*/
public class CheckVersion
{
- /**
+ /*
* Check for the existence of a class by attempting to load it
*/
public static boolean checkClass(String c)
return true;
}
- /**
+ /*
* This first checks java.vm.version for 1.1, 1.2 or 1.3.
*
* It writes jdbc1 to stdout for the 1.1.x VM.