Re: database toolbox problem
- From: "Stefan " <jo@xxxxxxxxx>
- Date: Wed, 5 Mar 2008 14:38:02 +0000 (UTC)
I have found a workaround for this problem.
This bug is already listed in the Matlab bug reports and
currently there is no solution available.
Searching the net I have found some hints for a workaround
using the jdbc connector.
WORKAROUND-------------------------
import java.lang.Thread
import java.lang.Class
import java.sql.DriverManager
current_thread = java.lang.Thread.currentThread();
class_loader = current_thread.getContextClassLoader();
class = java.lang.Class.forName('com.mysql.jdbc.Driver',
true, class_loader);
database_url = 'jdbc:mysql://localhost/seismon';
conn = java.sql.DriverManager.getConnection(database_url,
'seismon', 'seismon');
stmt = conn.createStatement();
query = 'ALTER TABLE test ADD test_col VARCHAR(10) NOT NULL';
result = stmt.execute(query);
% % This command produces the know error message:
% result = stmt.executeQuery(query);
-----------------------------------
The workaround is based on the following solution of a mysql
bug report:
"The JDBC spec states that you must either use
Statement.executeUpdate() or Statement.execute() for queries
that manipulate data (such as your 'UPDATE documents SET
web_exp....' query).
Older versions of the JDBC driver were more lax on this.
However, it is important to be
JDBC-compliant, so the later versions of the driver enforce
this requirement."
The coding is taken from:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/161242
Until later,
Stefan.
"Stefan " <jo@xxxxxxxxx> wrote in message
<fqm5m9$lfh$1@xxxxxxxxxxxxxxxxxx>...
Hello,database('datasourcename','username','password','com.mysql.jdbc.Driver',
I have a problem using the database toolbox exec function.
I'd like to add columns to a table. Using the jdbc connector
and the command exec(conn, query) results in the following
error:
'Can not issue data manipulation statements with
executeQuery().'
I have read on the mysql homepage, that this error occurs
with the jdbc connector when using the wrong java command:
"The JDBC spec states that you must either use
Statement.executeUpdate() or
Statement.execute() for queries that manipulate data (such
as your 'UPDATE documents SET
web_exp....' query).
Older versions of the JDBC driver were more lax on this.
However, it is important to be
JDBC-compliant, so the later versions of the driver enforce
this requirement."
Here is my code:
conn =
'jdbc:mysql://localhost/dbUrl');
query = 'ALTER TABLE test ADD type VARCHAR(10) NOT NULL
AFTER id, ADD domain VARCHAR(45) NOT NULL';
curs = exec(conn, curQuery);
The query works when using the mysql command line.
Is there a way to solve this problem in matlab?
Best regards,
Stefan.
.
- References:
- database toolbox problem
- From: Stefan
- database toolbox problem
- Prev by Date: Re: this is for the vectorization experts!
- Next by Date: Re: speeding up: min(A(A>0))
- Previous by thread: Re: database toolbox problem
- Next by thread: speeding up: min(A(A>0))
- Index(es):
Relevant Pages
|