Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 4ea4b2b

Browse files
author
Chris Board
committed
Bug fixes and support for blob data
Added a fix where MySQL 5.7 wouldn't parse SQL error packets successfully. Added support for getBlobs (was added to the master but this branch)
1 parent ba6e994 commit 4ea4b2b

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed
0 Bytes
Binary file not shown.

.idea/gradle.xml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AndroidMySQLConnector/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ else
2020
}
2121

2222
archivesBaseName="AndroidMySQLConnector"
23-
version '0.37'
23+
version '0.39'
2424
group 'com.BoardiesITSolutions'
2525

2626

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/MySQLIO.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ private void getSocketData() throws IOException
134134
}
135135
packetType = tempFullData[tempFullData.length-1 - 8];
136136
Log.d("MySQIO", "Less than 1024 bytes returned. Packet type -8 from the end of the array would need to be an EOF packet");
137-
if (packetType == 0xfe)
137+
if (packetType == 0xfe || packetType == 0xff)
138138
{
139139
break;
140140
}
141141
//The 4th byte can also contain the OK or EOF so check this as well
142-
if (tempFullData[4] == 0x00 || tempFullData[4] == 0xfe)
142+
if (tempFullData[4] == 0x00 || tempFullData[4] == 0xfe || tempFullData[4] == 0xff)
143143
{
144144
break;
145145
}
@@ -149,6 +149,10 @@ private void getSocketData() throws IOException
149149
Log.d("ByteData", "Index: " + i + " Value: " + tempFullData[i]);
150150
}*/
151151

152+
if (expectedPayloadLength == (tempFullData.length - 4))
153+
{
154+
break;
155+
}
152156
}
153157
//If we get here continue fetching data
154158

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/MySQLRow.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ public String getString(String column) throws SQLColumnNotFoundException
3636
throw new SQLColumnNotFoundException("'"+column+"' was not found in result set");
3737
}
3838

39+
public byte[] getBlob(String column) throws SQLColumnNotFoundException
40+
{
41+
Set set = this.columnAndRowValue.entrySet();
42+
Iterator iterator = set.iterator();
43+
while (iterator.hasNext())
44+
{
45+
Map.Entry entry = (Map.Entry)iterator.next();
46+
ColumnDefinition col = (ColumnDefinition)entry.getKey();
47+
if (col.getColumnName().equals(column))
48+
{
49+
return (byte[])entry.getValue();
50+
}
51+
}
52+
throw new SQLColumnNotFoundException("'"+column+"' was not found in result set");
53+
}
54+
3955
public int getInt(String column) throws SQLColumnNotFoundException
4056
{
4157
String value = this.getString(column);

demoapplication/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ dependencies {
3030
implementation fileTree(dir: 'libs', include: ['*.jar'])
3131

3232
implementation 'androidx.appcompat:appcompat:1.1.0'
33-
implementation 'com.github.BoardiesITSolutions:Android-MySQL-Connector:0.37_MySQL8'
33+
implementation 'com.github.BoardiesITSolutions:Android-MySQL-Connector:0.39_MySQL8'
3434

3535
}

0 commit comments

Comments
 (0)