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

Commit

Permalink
Fixes issue with blobs
Browse files Browse the repository at this point in the history
Fixes issue with blob data retrieval
Fixes issue with data in a blog is actually string
Fixes typo where column type was being shown as BLOG instead of BLOB
  • Loading branch information
Chris Board committed Aug 5, 2020
1 parent be14e8a commit 0020aca
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 3 additions & 3 deletions AndroidMySQLConnector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
}

archivesBaseName="AndroidMySQLConnector"
version '0.41'
version '0.42'
group 'com.BoardiesITSolutions'


Expand All @@ -30,8 +30,8 @@ android {
//applicationId "com.BoardiesITSolutions.AndroidMySQLConnector"
minSdkVersion 19
targetSdkVersion 29
versionCode 29
versionName "0.41"
versionCode 30
versionName "0.42"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.BoardiesITSolutions.AndroidMySQLConnector;

import java.math.BigInteger;

import static java.lang.Math.abs;

public class ColumnDefinition
{
public enum ColumnType {
DECIMAL, TINY, SHORT, LONG, FLOAT, DOUBLE, NULL, TIMESTAMP, LONGLONG, INT24, DATE, TIME, DATETIME, YEAR,
NEWDATE, VARCHAR, BIT, TIMESTAMP2, DATETIME2, TIME2, NEWDECIMAL, ENUM, SET, TINY_BLOB, MEDIUM_BLOB,
LONG_BLOG, BLOG, VAR_STRING, STRING, GEOMETRY
LONG_BLOB, BLOB, VAR_STRING, STRING, GEOMETRY
}

/**
Expand Down Expand Up @@ -155,10 +153,10 @@ private void setColumnType(int columnType)
this.columnType = ColumnType.MEDIUM_BLOB;
break;
case 0xfb:
this.columnType = ColumnType.LONG_BLOG;
this.columnType = ColumnType.LONG_BLOB;
break;
case 0xfc:
this.columnType = ColumnType.BLOG;
this.columnType = ColumnType.BLOB;
break;
case 0xfd:
this.columnType = ColumnType.VAR_STRING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class MySQLRow
{
private HashMap<ColumnDefinition, String> columnAndRowValue;
private HashMap<ColumnDefinition, Object> columnAndRowValue;

public MySQLRow()
{
Expand All @@ -20,7 +20,7 @@ public int getSizeOfHash()
return this.columnAndRowValue.size();
}

public void addRowValue(ColumnDefinition columnDefinition, String rowValue)
public void addRowValue(ColumnDefinition columnDefinition, Object rowValue)
{
this.columnAndRowValue.put(columnDefinition, rowValue);
}
Expand Down Expand Up @@ -51,12 +51,21 @@ public byte[] getBlob(String column) throws SQLColumnNotFoundException
ColumnDefinition col = (ColumnDefinition)entry.getKey();
if (col.getColumnName().equals(column))
{
return (byte[])entry.getValue();
if (entry.getValue() instanceof String)
{
return (byte[])entry.getValue().toString().getBytes();
}
else
{
return (byte[]) entry.getValue();
}
}
}
throw new SQLColumnNotFoundException("'"+column+"' was not found in result set");
}



public int getInt(String column) throws SQLColumnNotFoundException
{
String value = this.getString(column);
Expand Down
2 changes: 1 addition & 1 deletion demoapplication/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.github.BoardiesITSolutions:Android-MySQL-Connector:0.41_MySQL8'
implementation 'com.github.BoardiesITSolutions:Android-MySQL-Connector:0.42_MySQL8'

}

0 comments on commit 0020aca

Please sign in to comment.