comparison src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiStartOfHeaderParser.java @ 93:eeb71f7d36bf embedded

Fixed a bug on the JDBC MAPI connection from the old code! Fixed the connection properties for an JDBC Embedded connection. To start a JDBC Embedded connection, the user must start the embedded database beforehand with the method MonetDBEmbeddedDatabase.StartDatabase().
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Fri, 06 Jan 2017 12:36:33 +0000 (2017-01-06)
parents 6f74e01c57da
children 4bb4e988164d
comparison
equal deleted inserted replaced
91:6f74e01c57da 93:eeb71f7d36bf
19 case '0': 19 case '0':
20 res = StarterHeaders.Q_PARSE; 20 res = StarterHeaders.Q_PARSE;
21 break; 21 break;
22 case '1': 22 case '1':
23 res = StarterHeaders.Q_TABLE; 23 res = StarterHeaders.Q_TABLE;
24 protocol.lineBuffer.get();
24 break; 25 break;
25 case '2': 26 case '2':
26 res = StarterHeaders.Q_UPDATE; 27 res = StarterHeaders.Q_UPDATE;
28 protocol.lineBuffer.get();
27 break; 29 break;
28 case '3': 30 case '3':
29 res = StarterHeaders.Q_SCHEMA; 31 res = StarterHeaders.Q_SCHEMA;
30 break; 32 break;
31 case '4': 33 case '4':
32 res = StarterHeaders.Q_TRANS; 34 res = StarterHeaders.Q_TRANS;
33 break; 35 break;
34 case '5': 36 case '5':
35 res = StarterHeaders.Q_PREPARE; 37 res = StarterHeaders.Q_PREPARE;
38 protocol.lineBuffer.get();
36 break; 39 break;
37 case '6': 40 case '6':
38 res = StarterHeaders.Q_BLOCK; 41 res = StarterHeaders.Q_BLOCK;
42 protocol.lineBuffer.get();
39 break; 43 break;
40 default: 44 default:
41 res = StarterHeaders.Q_UNKNOWN; 45 res = StarterHeaders.Q_UNKNOWN;
42 } 46 }
43 return res; 47 return res;
49 char[] array = protocol.lineBuffer.array(); 53 char[] array = protocol.lineBuffer.array();
50 54
51 if (currentPointer >= limit) { 55 if (currentPointer >= limit) {
52 throw new ProtocolException("unexpected end of string", currentPointer - 1); 56 throw new ProtocolException("unexpected end of string", currentPointer - 1);
53 } 57 }
54 int tmp; 58 int tmp = 0, negative = 1;;
55 char chr = array[currentPointer++]; 59 char chr = array[currentPointer++];
56 // note: don't use Character.isDigit() here, because we only want ISO-LATIN-1 digits 60 // note: don't use Character.isDigit() here, because we only want ISO-LATIN-1 digits
57 if (chr >= '0' && chr <= '9') { 61 if (chr >= '0' && chr <= '9') {
58 tmp = (int)chr - (int)'0'; 62 tmp = (int)chr - (int)'0';
63 } else if(chr == '-') {
64 negative = -1;
59 } else { 65 } else {
60 throw new ProtocolException("expected a digit", currentPointer - 1); 66 throw new ProtocolException("expected a digit", currentPointer - 1);
61 } 67 }
62 68
63 while (currentPointer < limit) { 69 while (currentPointer < limit) {
70 tmp += (int)chr - (int)'0'; 76 tmp += (int)chr - (int)'0';
71 } else { 77 } else {
72 throw new ProtocolException("expected a digit", currentPointer - 1); 78 throw new ProtocolException("expected a digit", currentPointer - 1);
73 } 79 }
74 } 80 }
81 tmp *= negative;
75 protocol.lineBuffer.position(currentPointer); 82 protocol.lineBuffer.position(currentPointer);
76 return tmp; 83 return tmp;
77 } 84 }
78 85
79 static String GetNextResponseDataAsString(OldMapiProtocol protocol) throws ProtocolException { 86 static String GetNextResponseDataAsString(OldMapiProtocol protocol) throws ProtocolException {