001: /*
002: * Copyright (C) CollabraSpace Inc. All rights reserved.
003: */
004: package adhoc;
005:
006: import java.sql.Connection;
007: import java.sql.DriverManager;
008: import java.sql.PreparedStatement;
009: import java.sql.SQLException;
010: import java.sql.Types;
011:
012: public class PointbaseBLOBTest {
013:
014: String jdbcUrl = "jdbc:pointbase:server://localhost:9093/workshop";
015:
016: String user = "csuite";
017:
018: String pass = "csuite";
019:
020: Connection con = null;
021:
022: String insertSQL = "insert into CSUITE.CS_BUILDING "
023: + "(ID, CAMPUS_ID, NAME, DESCRIPTION, IMAGE_BYTES, MOTD, "
024: + "ADMINISTRATORS_ID, CREATION_DATE, MODIFICATION_DATE) "
025: + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
026:
027: String insertSQLWithoutBlob = "insert into CSUITE.CS_BUILDING "
028: + "(ID, CAMPUS_ID, NAME, DESCRIPTION, MOTD, "
029: + "ADMINISTRATORS_ID, CREATION_DATE, MODIFICATION_DATE) "
030: + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
031:
032: long id = 1;
033: long campusId = 1127416427999l;
034: long administratorsId = 7;
035: long creationDate = 1127416677218l;
036: long modificationDate = 1127416677218l;
037:
038: public PointbaseBLOBTest() throws Exception {
039: init();
040: }
041:
042: public void init() throws Exception {
043: Class.forName("com.pointbase.jdbc.jdbcUniversalDriver");
044: con = DriverManager.getConnection(jdbcUrl, user, pass);
045: }
046:
047: /**
048: * This fails with a Connection failure - java.io.EOFException
049: * @throws SQLException
050: */
051: public void doTest() throws SQLException {
052: PreparedStatement ps = con.prepareStatement(insertSQL);
053:
054: ps.setLong(1, id);
055: ps.setLong(2, campusId);
056: ps.setString(3, "c1b1");
057: ps.setNull(4, Types.VARCHAR);
058: ps.setNull(5, Types.LONGVARBINARY);
059: ps.setNull(6, Types.VARCHAR);
060: ps.setLong(7, administratorsId);
061: ps.setLong(8, creationDate);
062: ps.setLong(9, modificationDate);
063: int rowCount = ps.executeUpdate();
064: System.out.println("Inserted " + rowCount
065: + " rows successfully");
066:
067: ps.close();
068: }
069:
070: /**
071: * This fails with a Connection failure - java.io.EOFException
072: * @throws SQLException
073: */
074: public void doTestWithoutBlob() throws SQLException {
075: PreparedStatement ps = con.prepareStatement(insertSQL);
076:
077: ps.setLong(1, id);
078: ps.setLong(2, campusId);
079: ps.setString(3, "c1b1");
080: ps.setNull(4, Types.VARCHAR);
081: ps.setNull(5, Types.VARCHAR);
082: ps.setLong(6, administratorsId);
083: ps.setLong(7, creationDate);
084: ps.setLong(8, modificationDate);
085: int rowCount = ps.executeUpdate();
086: System.out.println("Inserted " + rowCount
087: + " rows successfully");
088:
089: ps.close();
090: }
091:
092: public void shutdown() throws SQLException {
093: con.close();
094: }
095:
096: /**
097: * @param args
098: */
099: public static void main(String[] args) throws Exception {
100: // TODO Auto-generated method stub
101: PointbaseBLOBTest test = new PointbaseBLOBTest();
102:
103: test.doTest();
104:
105: test.shutdown();
106: }
107:
108: }
|