james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: james-server/src/java/org/apache/james/mailrepository JDBCMailRepository.java MimeMessageJDBCSource.java
Date Wed, 14 Apr 2004 06:06:59 GMT
noel        2004/04/13 23:06:59

  Modified:    src/conf Tag: branch_2_1_fcs sqlResources.xml
               src/java/org/apache/james/mailrepository Tag: branch_2_1_fcs
                        JDBCMailRepository.java MimeMessageJDBCSource.java
  Log:
  Fix JAMES-247.  Oracle did not permit two raw columns.  Also adds db2 support.  Patch contributed
by Steve Short.  Looks OK.  Blob type introduced in JDBC 1.2, and we'd want to switch to that
anyway as we move to use streaming.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.16.4.9  +42 -5     james-server/src/conf/sqlResources.xml
  
  Index: sqlResources.xml
  ===================================================================
  RCS file: /home/cvs/james-server/src/conf/sqlResources.xml,v
  retrieving revision 1.16.4.8
  retrieving revision 1.16.4.9
  diff -u -r1.16.4.8 -r1.16.4.9
  --- sqlResources.xml	16 Nov 2003 21:47:24 -0000	1.16.4.8
  +++ sqlResources.xml	14 Apr 2004 06:06:59 -0000	1.16.4.9
  @@ -22,6 +22,7 @@
       <dbMatcher db="postgresql" databaseProductName="postgres.*"/>
       <dbMatcher db="sapdb" databaseProductName="sap.*"/>
       <dbMatcher db="hypersonic" databaseProductName="HypersonicSQL"/>
  +    <dbMatcher db="db2" databaseProductName="db2.*"/>
   </dbMatchers>
   
   <!-- SQL statements to use for various components. -->
  @@ -195,6 +196,8 @@
       <sql name="retrieveMessageBodySizeSQL" db="mysql">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
       <sql name="retrieveMessageBodySizeSQL" db="hypersonic">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
       <sql name="retrieveMessageBodySizeSQL" db="postgresql">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
  +    <sql name="retrieveMessageBodySizeSQL" db="oracle">SELECT dbms_lob.getlength(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
  +    <sql name="retrieveMessageBodySizeSQL" db="db2">SELECT length(message_body) FROM
${table} WHERE message_name = ? AND repository_name = ?</sql>
   
       <!-- Statements used to delete a message stored in this repository. -->
       <sql name="removeMessageSQL">DELETE FROM ${table} WHERE message_name = ? AND
repository_name = ?</sql>
  @@ -261,12 +264,11 @@
           recipients varchar2(1000) NOT NULL ,
           remote_host varchar2(100) NOT NULL ,
           remote_addr varchar2(20) NOT NULL ,
  -        message_body long raw NOT NULL ,
  -        message_attributes long raw NULL ,
  +        message_body blob NOT NULL ,
  +        message_attributes blob NULL ,
           last_updated date NOT NULL ,
           PRIMARY KEY (repository_name, message_name)
           )
  -        TABLESPACE system
       </sql>
       <sql name="createTable" db="postgresql">
           CREATE TABLE ${table} (
  @@ -300,6 +302,22 @@
               PRIMARY KEY (repository_name, message_name)
           )
       </sql>
  +    <sql name="createTable" db="db2">
  +        CREATE TABLE ${table} (
  +        message_name varchar(200) NOT NULL ,
  +        repository_name varchar(255) NOT NULL ,
  +        message_state varchar(30) NOT NULL ,
  +        error_message varchar(200) ,
  +        sender varchar(255) ,
  +        recipients varchar(1000) NOT NULL ,
  +        remote_host varchar(100) NOT NULL ,
  +        remote_addr varchar(20) NOT NULL ,
  +        message_body blob NOT NULL ,
  +        message_attributes blob ,
  +        last_updated timestamp NOT NULL ,
  +        PRIMARY KEY (repository_name, message_name)
  +        )
  +    </sql>
   </sqlDefs>
   
   <!-- SQL statements to support the JDBCSpoolRepository class -->
  @@ -341,6 +359,8 @@
       <sql name="retrieveMessageBodySizeSQL" db="mysql">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
       <sql name="retrieveMessageBodySizeSQL" db="hypersonic">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
       <sql name="retrieveMessageBodySizeSQL" db="postgresql">SELECT length(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
  +    <sql name="retrieveMessageBodySizeSQL" db="oracle">SELECT dbms_lob.getlength(message_body)
FROM ${table} WHERE message_name = ? AND repository_name = ?</sql>
  +    <sql name="retrieveMessageBodySizeSQL" db="db2">SELECT length(message_body) FROM
${table} WHERE message_name = ? AND repository_name = ?</sql>
   
       <!-- Statements used to delete a message stored in this repository. -->
       <sql name="removeMessageSQL">DELETE FROM ${table} WHERE message_name = ? AND
repository_name = ?</sql>
  @@ -407,8 +427,8 @@
           recipients varchar2(1000) NOT NULL ,
           remote_host varchar2(255) NOT NULL ,
           remote_addr varchar2(20) NOT NULL ,
  -        message_body long raw NOT NULL ,
  -        message_attributes long raw NULL ,
  +        message_body blob NOT NULL ,
  +        message_attributes blob NULL ,
           last_updated date NOT NULL ,
           PRIMARY KEY (message_name, repository_name)
           )
  @@ -445,6 +465,23 @@
               PRIMARY KEY (message_name, repository_name)
           )
       </sql>
  +    <sql name="createTable" db="db2">
  +        CREATE TABLE ${table} (
  +        message_name varchar(200) NOT NULL ,
  +        repository_name varchar(255) NOT NULL ,
  +        message_state varchar(30) NOT NULL ,
  +        error_message varchar(200) ,
  +        sender varchar(255) ,
  +        recipients varchar(1000) NOT NULL ,
  +        remote_host varchar(100) NOT NULL ,
  +        remote_addr varchar(20) NOT NULL ,
  +        message_body blob NOT NULL ,
  +        message_attributes blob ,
  +        last_updated timestamp NOT NULL ,
  +        PRIMARY KEY (repository_name, message_name)        
  +        )
  +    </sql>
   </sqlDefs>
   
   </sqlResources>
  +
  
  
  
  No                   revision
  No                   revision
  1.30.4.15 +3 -2      james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
  
  Index: JDBCMailRepository.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
  retrieving revision 1.30.4.14
  retrieving revision 1.30.4.15
  diff -u -r1.30.4.14 -r1.30.4.15
  --- JDBCMailRepository.java	20 Mar 2004 07:15:12 -0000	1.30.4.14
  +++ JDBCMailRepository.java	14 Apr 2004 06:06:59 -0000	1.30.4.15
  @@ -824,7 +824,8 @@
                       
                       if (rsMessageAttr.next()) {
                           try {
  -                            byte[] serialized_attr = rsMessageAttr.getBytes(1);
  +                            Blob b = rsMessageAttr.getBlob(1);
  +                            byte[] serialized_attr = b.getBytes(1, (int)b.length());
                               // this check is for better backwards compatibility
                               if (serialized_attr != null) {
                                   ByteArrayInputStream bais = new ByteArrayInputStream(serialized_attr);
  
  
  
  1.10.4.5  +3 -1      james-server/src/java/org/apache/james/mailrepository/MimeMessageJDBCSource.java
  
  Index: MimeMessageJDBCSource.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/mailrepository/MimeMessageJDBCSource.java,v
  retrieving revision 1.10.4.4
  retrieving revision 1.10.4.5
  diff -u -r1.10.4.4 -r1.10.4.5
  --- MimeMessageJDBCSource.java	15 Mar 2004 03:54:16 -0000	1.10.4.4
  +++ MimeMessageJDBCSource.java	14 Apr 2004 06:06:59 -0000	1.10.4.5
  @@ -25,6 +25,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.SequenceInputStream;
  +import java.sql.Blob;
   import java.sql.Connection;
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
  @@ -137,7 +138,8 @@
                   throw new IOException("Could not find message");
               }
   
  -            headers = rsRetrieveMessageStream.getBytes(1);
  +            Blob b = rsRetrieveMessageStream.getBlob(1);
  +            headers = b.getBytes(1, (int)b.length());
               if (DEEP_DEBUG) {
                   System.err.println("stopping");
                   System.err.println(System.currentTimeMillis() - start);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message