Changeset: 6f74e01c57da for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=6f74e01c57da
Added Files:
        src/main/java/nl/cwi/monetdb/jdbc/MonetINET.java
Removed Files:
        src/main/java/nl/cwi/monetdb/jdbc/types/MonetINET.java
        src/main/java/nl/cwi/monetdb/jdbc/types/MonetURL.java
Modified Files:
        build.xml
        example/MJDBCTest.java
        example/PreparedExample.java
        example/SQLImport.java
        example/SQLcopyinto.java
        src/main/java/nl/cwi/monetdb/client/JMonetDB.java
        src/main/java/nl/cwi/monetdb/client/JdbcClient.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
        src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetSavepoint.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java
        src/main/java/nl/cwi/monetdb/jdbc/MonetWrapper.java
        src/main/java/nl/cwi/monetdb/mcl/connection/ControlCommands.java
        src/main/java/nl/cwi/monetdb/mcl/connection/IMonetDBLanguage.java
        src/main/java/nl/cwi/monetdb/mcl/connection/MCLException.java
        src/main/java/nl/cwi/monetdb/mcl/connection/SenderThread.java
        
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/BufferReallocator.java
        src/main/java/nl/cwi/monetdb/mcl/connection/helpers/ChannelSecurity.java
        
src/main/java/nl/cwi/monetdb/mcl/connection/helpers/GregorianCalendarParser.java
        src/main/java/nl/cwi/monetdb/mcl/connection/mapi/AbstractSocket.java
        src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiConnection.java
        src/main/java/nl/cwi/monetdb/mcl/connection/mapi/MapiLanguage.java
        src/main/java/nl/cwi/monetdb/mcl/connection/mapi/OldMapiSocket.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/newmapi/NewMapiProtocol.java
        src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiServerResponseParser.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTableHeaderParser.java
        
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiTupleLineParser.java
        src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/IIncompleteResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/IResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/SchemaResponse.java
        src/main/java/nl/cwi/monetdb/mcl/responses/UpdateResponse.java
        src/main/java/nl/cwi/monetdb/merovingian/Control.java
        src/main/java/nl/cwi/monetdb/merovingian/MerovingianException.java
        src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java
        src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java
        src/main/java/nl/cwi/monetdb/util/Exporter.java
        src/main/java/nl/cwi/monetdb/util/Extract.java
        src/main/java/nl/cwi/monetdb/util/OptionsException.java
        src/main/java/nl/cwi/monetdb/util/SQLExporter.java
        src/main/java/nl/cwi/monetdb/util/SQLRestore.java
        src/main/java/nl/cwi/monetdb/util/XMLExporter.java
        tests/BugConcurrent_clients_SF_1504657.java
        tests/BugConcurrent_sequences.java
        tests/BugDatabaseMetaData_Bug_3356.java
        tests/BugDecimalRound_Bug_3561.java
        tests/BugExecuteUpdate_Bug_3350.java
        tests/BugSetQueryTimeout_Bug_3357.java
        tests/Test_Cautocommit.java
        tests/Test_Cforkbomb.java
        tests/Test_CisValid.java
        tests/Test_Clargequery.java
        tests/Test_Cmanycon.java
        tests/Test_Creplysize.java
        tests/Test_Csavepoints.java
        tests/Test_Csendthread.java
        tests/Test_Ctransaction.java
        tests/Test_Dobjects.java
        tests/Test_FetchSize.java
        tests/Test_Int128.java
        tests/Test_PSgeneratedkeys.java
        tests/Test_PSgetObject.java
        tests/Test_PSlargeamount.java
        tests/Test_PSlargebatchval.java
        tests/Test_PSlargeresponse.java
        tests/Test_PSmanycon.java
        tests/Test_PSmetadata.java
        tests/Test_PSsomeamount.java
        tests/Test_PSsqldata.java
        tests/Test_PStimedate.java
        tests/Test_PStimezone.java
        tests/Test_PStypes.java
        tests/Test_Rbooleans.java
        tests/Test_Rmetadata.java
        tests/Test_Rpositioning.java
        tests/Test_Rsqldata.java
        tests/Test_Rtimedate.java
        tests/Test_Sbatching.java
        tests/Test_Smoreresults.java
        tests/Test_Wrapper.java
        tests/build.xml
        tests/drop.sql
        version.sh
Branch: embedded
Log Message:

Made fixings regarding the null values retrieval. The JDBC embedded connection 
is working!!! :) Some more testing, optimizations and compilations fixes are 
still required.


diffs (truncated from 1788 to 300 lines):

diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -5,7 +5,7 @@ This Source Code Form is subject to the 
 License, v. 2.0.  If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
 -->
 
 <!--
diff --git a/example/MJDBCTest.java b/example/MJDBCTest.java
--- a/example/MJDBCTest.java
+++ b/example/MJDBCTest.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 import java.sql.*;
diff --git a/example/PreparedExample.java b/example/PreparedExample.java
--- a/example/PreparedExample.java
+++ b/example/PreparedExample.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 import java.sql.*;
diff --git a/example/SQLImport.java b/example/SQLImport.java
--- a/example/SQLImport.java
+++ b/example/SQLImport.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 import java.sql.*;
diff --git a/example/SQLcopyinto.java b/example/SQLcopyinto.java
--- a/example/SQLcopyinto.java
+++ b/example/SQLcopyinto.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 import java.sql.*;
diff --git a/src/main/java/nl/cwi/monetdb/client/JMonetDB.java 
b/src/main/java/nl/cwi/monetdb/client/JMonetDB.java
--- a/src/main/java/nl/cwi/monetdb/client/JMonetDB.java
+++ b/src/main/java/nl/cwi/monetdb/client/JMonetDB.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.client;
diff --git a/src/main/java/nl/cwi/monetdb/client/JdbcClient.java 
b/src/main/java/nl/cwi/monetdb/client/JdbcClient.java
--- a/src/main/java/nl/cwi/monetdb/client/JdbcClient.java
+++ b/src/main/java/nl/cwi/monetdb/client/JdbcClient.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.client;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetBlob.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.jdbc;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetClob.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.jdbc;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -1,7 +1,5 @@
 package nl.cwi.monetdb.jdbc;
 
-import nl.cwi.monetdb.jdbc.types.MonetINET;
-import nl.cwi.monetdb.jdbc.types.MonetURL;
 import nl.cwi.monetdb.mcl.connection.*;
 import nl.cwi.monetdb.mcl.connection.SenderThread;
 import nl.cwi.monetdb.mcl.connection.mapi.MapiLanguage;
@@ -72,7 +70,6 @@ public abstract class MonetConnection ex
     private Map<String,Class<?>> typeMap = new HashMap<String,Class<?>>() {
         private static final long serialVersionUID = 1L; {
             put("inet", MonetINET.class);
-            put("url",  MonetURL.class);
         }
     };
 
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDataSource.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.jdbc;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.jdbc;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in
@@ -3,7 +3,7 @@
  * License, v. 2.0.  If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
  */
 
 package nl.cwi.monetdb.jdbc;
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetINET.java 
b/src/main/java/nl/cwi/monetdb/jdbc/MonetINET.java
new file mode 100644
--- /dev/null
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetINET.java
@@ -0,0 +1,169 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2017 MonetDB B.V.
+ */
+
+package nl.cwi.monetdb.jdbc;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.sql.SQLData;
+import java.sql.SQLException;
+import java.sql.SQLInput;
+import java.sql.SQLOutput;
+
+/**
+ * The INET class represents the INET datatype in MonetDB.  It
+ * represents a IPv4 address with a certain mask applied.  Currently,
+ * IPv6 is not supported.
+ * <br />
+ * The input format for INET is x.x.x.x/y where x.x.x.x is an IP address
+ * and y is the number of bits in the netmask. If the /y part is left
+ * off, then the netmask is 32, and the value represents just a single
+ * host. On display, the /y portion is suppressed if the netmask is 32.
+ * <br />
+ * This class allows to retrieve the value of this INET as InetAddress.
+ * This is probably meaningful only and only if the netmask is 32.  The
+ * getNetmaskBits() method can be used to retrieve the subnet bits.
+ */
+public class MonetINET implements SQLData {
+
+       private static String FromString(String newinet) throws Exception {
+               if (newinet == null) {
+                       return null;
+               }
+               int slash = newinet.indexOf('/');
+               String tinet = newinet;
+               if (slash != -1) {
+                       int netmask;
+                       // ok, see if it is a valid netmask
+                       try {
+                               netmask = 
Integer.parseInt(newinet.substring(slash + 1));
+                       } catch (NumberFormatException nfe) {
+                               throw new Exception("cannot parse netmask bits: 
" + newinet.substring(slash + 1));
+                       }
+                       if (netmask <= 0 || netmask > 32)
+                               throw new Exception("netmask must be >0 and 
<32");
+                       tinet = newinet.substring(0, slash);
+               }
+               // check dotted quad
+               String quads[] = tinet.split("\\.");
+               if (quads.length != 4)
+                       throw new Exception("expected dotted quad 
(xxx.xxx.xxx.xxx)");
+               for (int i = 0; i < 4; i++) {
+                       int quadv;
+                       try {
+                               quadv = Integer.parseInt(quads[i]);
+                       } catch (NumberFormatException nfe) {
+                               throw new Exception("cannot parse number: " + 
quads[i]);
+                       }
+                       if (quadv < 0 || quadv > 255)
+                               throw new Exception("value must be between 0 
and 255: " + quads[i]);
+               }
+               // everything is fine
+               return newinet;
+       }
+
+       private String inet;
+
+       public MonetINET(String inet) throws Exception {
+               this.inet = FromString(inet);
+       }
+
+       @Override
+       public String getSQLTypeName() {
+               return "inet";
+       }
+
+       @Override
+       public void readSQL(SQLInput stream, String typeName) throws 
SQLException {
+               if (typeName.compareTo("inet") != 0)
+                       throw new SQLException("can only use this class with 
'inet' type", "M1M05");
+               inet = stream.readString();
+       }
+
+       @Override
+       public void writeSQL(SQLOutput stream) throws SQLException {
+               stream.writeString(inet);
+       }
+
+       @Override
+       public String toString() {
+               return inet;
+       }
+
+       public void fromString(String newinet) throws Exception {
+               inet = FromString(newinet);
+       }
+
+       public String getAddress() {
+               if (inet == null)
+                       return null;
+
+               // inet optionally has a /y part, if y < 32, chop it off
+               int slash = inet.indexOf('/');
+               if (slash != -1)
+                       return inet.substring(0, slash);
+               return inet;
+       }
+
+       public void setAddress(String newinet) throws Exception {
+               if (newinet == null) {
+                       inet = null;
+                       return;
+               }
+               if (newinet.indexOf('/') != -1)
+                       throw new Exception("IPv4 address cannot contain '/' " 
+ "(use fromString() instead)");
+               fromString(newinet);
+       }
+
+       public int getNetmaskBits() throws SQLException {
+               if (inet == null)
+                       return 0;
+
+               // if netmask is 32, it is omitted in the output
+               int slash = inet.indexOf('/');
+               if (slash == -1)
+                       return 32;
+               try {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to