Matlab database explorer: Error using cursor/fetch (line 363) Java exception occurred: java.lang.OutOfMemoryError: Java heap space - matlab

I used the database explorer package to generate the following code.
function r = physicians()
%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'cellarray');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
%Make connection to database. Note that the password has been omitted.
%Using JDBC driver.
conn = database('censored', 'censored', '', 'Vendor', 'ORACLE', 'Server', 'cesnored', 'PortNumber', censored, 'DriverType', 'thin');
%Read data from database.
curs = exec(conn, ['SELECT RECIPIENT.RECIPIENT_ID'...
' , RECIPIENT.FNAME'...
' , RECIPIENT.LNAME'...
' , RECIPIENT.LANGUAGE'...
' , RECIPIENT.PHONE'...
' , RECIPIENT.FAX'...
' , RECIPIENT.CITY'...
' , RECIPIENT.POSTAL_CODE'...
' FROM "STI".RECIPIENT ']);
curs = fetch(curs);
close(curs);
%Assign data to output variable
r = curs.Data;
%Close database connection.
close(conn);
%Clear variables
clear curs conn
I get the following error:
Error using cursor/fetch (line 363)
Java exception occurred:
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.util.Vector.grow(Unknown Source)
at java.util.Vector.ensureCapacityHelper(Unknown Source)
at java.util.Vector.addElement(Unknown Source)
at com.mathworks.toolbox.database.fetchTheData.dataFetch(fetchTheData.java:763)
Error in physicians (line 24)
curs = fetch(curs);
However, when I just import directly using the tool, I don't get an error like this. I'm guessing I need to limit the amount of RAM being used, but I don't really know how.

Related

Making connection to hardware using MATLAB

I'm trying to make a connection to hardware (a controller of a moving stage) from Physik Insrumente using MATLAB. However, I have tried using the code that the company provided but did not work, so I have simplified but still doesn't work.
Here is my code:
addpath ( 'C:\Users\Public\PI\PI_MATLAB_Driver_GCS2' );
Controller = PI_GCS_Controller();
controllerSerialNumber = '118011005';
C867 = Controller.ConnectUSB(controllerSerialNumber);
display(C867.qIDN())
I am getting this error message:
PI_MATLAB_Driver_GCS2 loaded successfully.
Error using PI_GCS_Controller/ConnectUSB (line 17)
There is no interface or DLL handle with the given ID
Error in PI_GCS_Controller/ConnectUSB (line 17)
error(szDesc);
Error in PI_GCS_Controller/subsref (line 46)
varargout{1} = feval(fun,c,par{1});
Error in Untitled (line 5)
C867 = Controller.ConnectUSB(controllerSerialNumber);
ConnectUSB is:
function [c] = ConnectUSB(c,szIdentifier)
FunctionName = 'PI_ConnectUSB';
if(any(strcmp(FunctionName,c.dllfunctions)))
if(nargin<2), szIdentifier = blanks(5000); end,
try
[c.ID, szIdentifier] = calllib(c.libalias,FunctionName,szIdentifier);
if(c.ID<0)
iError = GetError(c);
szDesc = TranslateError(c,iError);
error(szDesc);
end
catch
rethrow(lasterror);
end
else
error('%s not found',FunctionName);
end
How can I connect to this controller?

Why does Perl DBI interface fail to INSERT to Postgres table?

I have develped a Perl script that can format data into CSV format, and want to save the data into a Postgres database table.
I'm following this tutorial as a guideline for how to interface to Postgres. I verified in the PPM that I have the same versions installed as the tutorial: 1.634 version of DBI and the 3.5.3 version of DBD::Pg installed in Perl 5.22.1 in Windows 10 x64. The database is Postgres 12 on Windows Server 2008r2.
The first part of the Perl script reads, parses, and formats one data record as CSV.
This is an example of one CSV data record:
"2020-05-10 20:39:16+0","0.528239011764526","15:39 05/10/2020","0x1c","LOW STATUS","0x85","Normal","73.8","32","29.11","29.31","61.2","29","80","0.7","2.5","22.6","378.64","3009","7","0.00","0.00","0.97","0.97","11.96"
This is stored in $SQLstring before entering the database interface snippet below:
This is the code I have modified from the tutorial, which compiles and runs without errors.
# ------------- Postgres Database Connection --------------
# Connection config
my $dbname = 'MyDatabase';
my $host = '192.168.1.1';
my $port = 5432;
my $username = 'myuser';
my $password = 'mypassword';
# Create DB handle object by connecting
my $dbh = DBI -> connect("dbi:Pg:dbname=$dbname;host=$host;port=$port",
$username,
$password,
{AutoCommit => 0, RaiseError => 1}
) or die $DBI::errstr;
# Trace to a file
$dbh -> trace(1, 'tracelog.txt');
# Copy from STDIN into the table
my $SQL = "COPY AmbientWeather (
datetimestamp ,
CurrTime ,
IndoorID ,
inBattSta ,
Outdoor1ID ,
outBattSta1 ,
inTemp ,
inHumi ,
AbsPress ,
RelPress ,
outTemp ,
outHumi ,
windir ,
avgwind ,
gustspeed ,
dailygust ,
solarrad ,
uv ,
uvi ,
rainofhourly ,
rainofdaily ,
rainofweekly ,
rainofmonthly ,
rainofyearly
)
FROM STDIN WITH DELIMITER ',' CSV HEADER";
my $sth = $dbh->do($SQL);
# putcopy data from saved line in CSV format
$dbh->pg_putcopydata($SQLstring);
$dbh->pg_putcopyend(); # finished with one line
$dbh->commit or die $DBI::errstr;
exit;
This runs without errors, but the database is unchanged. No record is created.
This is the trace log, which does not show any notable errors, but I am not really familiar with the syntax:
DBI::db=HASH(0x3c62268) trace level set to 0x0/1 (DBI # 0x0/0) in DBI 1.634-ithread (pid 19436)
<- DESTROY(DBI::db=HASH(0x3c62268))= ( undef ) [1 items] at Ambient_Parser.pl line 158
DBI::db=HASH(0x3c76ca8) trace level set to 0x0/1 (DBI # 0x0/0) in DBI 1.634-ithread (pid 2108)
<- do('COPY AmbientWeather (
datetimestamp ,
CurrTime ,
IndoorID ,
inBattSta ,
Outdoor1ID ,
outBattSta1 ,
inTemp ,
inHumi ,
AbsPress ,
RelPress ,
outTemp ,
outHumi ,
windir ,
avgwind ,
gustspeed ,
dailygust ,
solarrad ,
uv ,
uvi ,
rainofhourly ,
rainofdaily ,
rainofweekly ,
rainofmonthly ,
rainofyearly
...')= ( -1 ) [1 items] at Ambient_Parser.pl line 177
<- pg_putcopydata('"2020-05-10 20:35:59+0","0.547099113464355","15:35 05/10/2020","0x1c","LOW STATUS","0x85","Normal","73.6","32","29.11","29.31","61.3","24","193","3.8","4.9","22.6","380.54","3082","7","0.00","0.00","0.97","0.97","11.96"
')= ( 1 ) [1 items] at Ambient_Parser.pl line 182
<- pg_putcopyend= ( 1 ) [1 items] at Ambient_Parser.pl line 183
<- commit= ( 1 ) [1 items] at Ambient_Parser.pl line 184
<- DESTROY(DBI::db=HASH(0x3c76ca8))= ( undef ) [1 items] at Ambient_Parser.pl line 193
For reference line 193 is the final exit; in the file.
I must be missing something, but I don't see what it is. Can you point out my error?
Edit: I compared the options in the tutorial's command in my $SQL = "COPY.... with Postgres COPY command documentation. The tutorial adds options CSV HEADER, which are not seen in Postres docs. I'm not sure why those options are used in the tutorial, or why they cause a silent failure. I removed them and now I am getting errors.
Code from above now looks like this:
rainofyearly
)
FROM STDIN WITH DELIMITER ','";
These errors are now being output:
DBD::Pg::db pg_putcopyend failed: ERROR: invalid input syntax for type real: ""0.520319223403931""
CONTEXT: COPY ambientweather, line 1, column fetchelapsed: ""0.520319223403931"" at Ambient_Parser.pl line 186.
DBD::Pg::db pg_putcopyend failed: ERROR: invalid input syntax for type real: ""0.520319223403931""
CONTEXT: COPY ambientweather, line 1, column fetchelapsed: ""0.520319223403931"" at Ambient_Parser.pl line 186.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=MyDatabase;host=192.168.1.1;port=5432 at Ambient_Parser.pl line 186.
I'm investigating why the real value is being seen as double quoted. This is the same CSV format I have used from the PSQL command line with COPY FROM , and reals were accepted as shown above.
You told it the first line would be an ignored header. But you only sent it one line. So there were no data lines sent.
CSV and HEADER are separate options. These are both present (separately) in the docs you link to. You need to keep CSV, otherwise the quoting is not understood.

Undefined function or variable "Vk" when using sysic to create an interconnected system

I am attempting to use sysic to create an interconnected system from a number of state space models. However; I keep recieving the same error:
Undefined function or variable "Vk".
Error in sysic (line 212)
[ard,arl,er] = LOCALpass1(Vk);
Error in addOutputWeights (line 62)
sysic
The code used that generates this error is as follows:
systemnames = 'plantModel WControl WError';
inputvar = '[r(4); u(4)]';
outputvar = '[WControl; WError;r- plantModel]';
input_to_WError = '[r-plantModel]';
input_to_WControl = '[u]';
sysoutname = 'instramentedPlant';
cleanupsysic= 'yes';
sysic
This error was caused because input_to_plantModel was not present in the workspace. For every system that is refered to in systemnames there must be a corresponding input_to_X.
The following code runs correctly
systemnames='plantModel wControl wError';
inputvar ='[r(4); u(4)]';
outputvar ='[wControl;wError;r- plantModel]';
input_to_plantModel ='[u]';
input_to_wError ='[r-plantModel]';
input_to_wControl ='[u]';
sysoutname ='instramentedPlant';
cleanupsysic = 'yes';

MATLAB: errorn in butter() command

I wrote the following function:
function [output_signal] = AddDirectivityError (bat_loc_index, butter_deg_vector, sound_matrix)
global chirp_initial_freq ;
global chirp_end_freq;
global sampling_rate;
global num_of_mics;
global sound_signal_length;
for (i=1 : num_of_mics)
normalized_co_freq = (chirp_initial_freq + chirp_end_freq)/ (1.6* sampling_rate);
A=sound_matrix ( i, : ) ;
peak_signal=max(A);
B=find(abs(A)>peak_signal/100);
if (butter_deg_vector(i)==0)
butter_deg_vector(i)=2;
end
[num, den] = butter(butter_deg_vector(i), normalized_co_freq, 'low');// HERE!!!
filtered_signal=filter(num,den, A );
output_signal(i, :)=filtered_signal;
end
This functions runs many-many times without any error. However, when I reach the line: [num, den] = butter ( butter_deg_vector(i), normalized_co_freq, 'low');
And the local variables are: i=3, butter_deg_vector(i)=1, normalized_co_freq=5.625000e-001
MATLAB prompts an error says:
??? Error using ==> buttap Expected N to be integer-valued.
"Error in ==> buttap at 15 validateattributes(n,{'numeric'},{'scalar','integer','positive'},'buttap','N');
Error in ==> butter at 70 [z,p,k] = buttap(n);"
I don't understand why this problem occurs especially in this iteration. Why does this function prompt an error especially in this case?
Try to change the code line for:
[num, den] = butter (round(butter_deg_vector(i)), normalized_co_freq, 'low');

jdbc:mysql:replication causes Unknown column in 'field list' exception at runtime

I am using JBOSS EAP 5.1
want to implement Master/slave mechanism.
xyz-mysql-ds.xml (for ex. customer db)
xyz-mysql-ds.common.xml (for common db)
I have added master/slave ip in xyz-mysql-ds.xml
<local-tx-datasource>
<jndi-name>customerDS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:mysql:replication://master_ip_address:3306,slave_ip_address:3306/customer_v2_local?loadBalancePingTimeout=1500;loadBalanceBlacklistTimeout=7000;autoReconnect=true;failOverReadOnly=true;roundRobinLoadBalance=true</connection-url>
<driver-class>com.mysql.jdbc.ReplicationDriver</driver-class>
It starts JBOSS successfully. but geetting following error at runtime.
MySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list'com.mysql.jdbc.exceptions.jdbc4.M
ySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:155)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:342)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:209)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:258)
at org.hibernate.loader.Loader.doList(Loader.java:2233)
[wrapped] org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2236)
>>org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org
.hibernate.exception.SQLGrammarException: could not execute query
>>org.hibernate.exception.SQLGrammarException: could not execute query
[SQL: 1054, 42S22]
>>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'lkpmenuopt0_.SortOrder' in 'field list
'
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>> at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
>> at com.mysql.jdbc.Util.getInstance(Util.java:386)
>> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
>> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
>> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
>> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
>> at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
>> at com.mysql.jdbc.LoadBalancedMySQLConnection.execSQL(LoadBalancedMySQLConnection.java:155)
...
...
And if remove word relication from : <connection-url>jdbc:mysql:replication:
It working with NO runtime exception, but all read / write request goes to master only.
Any hint to solve this issue ?
Thanks !
<connection-url>jdbc:mysql:replication://master:3306,slave:3306/Customerdb?
loadBalancePingTimeout=1500&loadBalanceBlacklistTimeout=7000&autoReconnect=true&failOverReadOnly=true&roundRobinLoadBalance=true</connection-url>
<connection-url>jdbc:mysql:replication://master:3306,slave:3306/Customerdb?loadBalancePingTimeout=1500&loadBalanceBlacklistTimeout=7000&autoReconnect=true&failOverReadOnly=true&roundRobinLoadBalance=true</connection-url>
**finally this This works for me separating properties with &