I need to connect a MYSQL Database to Matlab in order to work with the measured data. I am using Matlab version 2014a and unfortunately don't have a Datatoolbox to acces.
I found after a lot of research following instruction:
http://hohonuuli.blogspot.com/2014/10/jdbc-and-matlab-simple-example.html
Unfortunately though it failed to get the connection to the database, I am stucked at the database.m script, while getting following error:
database
No method 'getConnection' with matching signature found for class 'java.sql.DriverManager'.
Error in database (line 29)
c = java.sql.DriverManager.getConnection('url', 'username', 'password',
'mysql-connector-java-5.1.46');
I used exactly the script in the following link above ( copy paste ) while putting my username,url,pw etc in.
I am not a programmer by any means but need to find a solution for that, if anyone can help me that would be awesome, THANK IN ADVANCE EIKE
Related
In PyCharm I created a MySQL schema using pymysql on my computer. Now I want to use Peewee to create tables and write the SQL queries. However, I always receive an error message (see below) when trying to connect to the DB.
The user has sufficient rights to create tables in the DB schema as it works flawlessly with pymysql (creating tables as well as the schema works fine).
I looked at similar questions on Stackoverflow and couldn't find a similar problem. Moreover, this problem wasn't experienced in any of the tutorials I looked at, so I'm not entirely sure what could be the culprit causing the error. Below is a minimal working example.
from peewee import*
import peewee
user = 'root'
password = 'root'
db_name = 'peewee_demo'
# The schema with the name 'peewee_demo' exists
db = MySQLDatabase(db_name, user=user, passwd=password)
class Book(peewee.Model):
author = peewee.CharField()
title = peewee.TextField()
class Meta:
database = db
db.connect() # Code fails here
Book.create_table()
book = Book(author="me", title='Peewee is cool')
book.save()
for book in Book.filter(author="me"):
print(book.title)
I would expect the above code to connect to MySQL and then create a new table in the schema "peewee_demo". But instead, the code throws an error message when trying to connect to the DB:
/usr/bin/python3.6: Relink '/lib/x86_64-linux-gnu/libsystemd.so.0' with /lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol clock_gettime'
/usr/bin/python3.6: Relink /lib/x86_64-linux-gnu/libudev.so.1' with /lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
Do you have any ideas how to fix this issue?
Thanks in advance
As #coleifer pointed out in his comment, the error was probably related to a shared library issue in Python. After setting up a new virtual environment and installing all required packages, everything runs perfectly fine.
I just added the answer to be able to close the question. If #coleifer converts his comment into an answer, I'll delete mine and accept his.
I have SQLite and MySQL installed on my local and development machine respectively. Following is working fine on my local machine(with SQLite):
select_single = {'date': "strftime('%%Y-%%m-%%d',projectName_Modelname.created)"}
queryset.extra(select=select_single)
But since strftime doesn't work with MySQL(link), I tried using DATE_FORMAT() as suggested in given link and other places too.
Though now when I execute below:
select_single = {'date': "DATE_FORMAT(projectName_Modelname.created, '%%Y-%%m-%%d')"}
queryset.extra(select=select_single)
Following error comes:
DatabaseError: (1054, "Unknown column 'projectName_Modelname.created' in 'field list'")
where 'created' is Datetime field in Django model 'Modelname' of app 'projectName'
To debug when I replace projectName_Modelname.created with NOW() no error comes. I have also tried just Modelname.created instead of projectName_Modelname.created though with no benefit?
Note: I am using Django1.5.5
I think it should be something like:
date_raw_query = {'date': "date_format(created, '%%Y-%%m-%%d')"}
and then try
queryset.extra(select=date_raw_query)
Hope that works in your setup. I have tried this on Django 1.7 and MySQL and seems to be working.
Also remember that if SQL errors start coming up, you can always do a print queryset.extra(select=date_raw_query).query to see what might be going wrong.
And when it comes to writing compatible code between SQLite and MySQL like this one, writing a custom MySQL function has been suggested here
But I would suggest otherwise. It's better to have a similar dev environment with MySQL setup in local and also, upgrade Django as soon as possible. :P
There's something I've done a hundred times: exporting a mysql database from one server and importing it into another. The export function provides an .sql file which then gets imported to the new server. However, my servers recently updated their phpMyAdmin version (currently 4.6.0) and now whenever I try to do that I get an error when trying to import. I think that has something to do with the escaping as one of the lines now looks like that in the exported file:
(5, 'that\\\'s not even', '2014-05-25 22:35:51', 0)
That is a part of INSERT statement for one of the tables and the triple \\\ is what bothers me. I've tried to look around the configuration and find something related to the escaping but alas no luck. No sure if that's the issue really but any tip on what might be wrong and how to fix it is more than welcome.
EDIT:
In face, that line seems to have nothing in common with the error. The error that gets displayed on import is the following:
Static analysis:
1 errors were found during analysis.
Ending quote ' was expected. (near "" at position 2615077)
After that a very long query follows and I also don't know if that's relevant or not but it ends with this following line which is far from being last:
(33, 'active_plugins', 'a:2:{i:0;s:37:"admin-in-english/admin-in-english.php";i:1;s:29:"filedownload/filedownload.php";}', 'yes'),
That last one in particular is from a bunch of WordPress tables in the database if that matters.
EDIT2:
And here's something even more interesting. I keep backups of old database dumps so I tried to import a dump from a couple of months back that definitely imported successfully back then. Right now, same file, but error once I try to do the import...
After a lot of headbanging it turns out that the problem was limitations imposed by PHP for files larger than 6MB. After 6MB of query it would just cut it right there and logically throw and error afterwards.
The solution is either to change them or in my case, as I don't have direct access to the configuration files: SSH import worked successfully.
I'm new to the whole pimcore thing. I am trying to play around and create classes. The issue is, I am not able to create more than 1 class, and in the database it is nameless, so when I try to create another class, it also tries to store it in the database with no name, which ends up showing an SQL error saying that there is a duplicate entry. Any ideas what the reason behind this could be?
I installed pimcore on an nginx server, I am trying to create classes by choosing Settings->Objects->Classes and then "Add Class", creating the first class was ok, I entered a name for the class and it was successfully added, however the name field in the corresponding database entry is empty, as in empty string ' '. So, when I try to add another class and pimcore attempts to store it in the table "classes", it returns an error saying that it would be a duplicate entry since they both are nameless, i.e. the name entered isn't added. The following error is what I managed to find using developer tools, could be helpful.
[WARN] Unable to parse the JSON returned by the server
minified_javascript_core_f5757da….js?_dc=3708:5684 Error: You're trying to decode an invalid JSON String:
Fatal error: Call to a member function hasChilds() on null in /var/www/html/pimproject/pimcore/modules/admin/controllers/DocumentController.php on line 59
at new Ext.Error (http://192.10.0.0/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:27054)
at Function.Ext.apply.raise (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:27447)
at Object.Ext.raise (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:27594)
at Object.Ext.JSON.me.decode (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:385102)
at Ext.define.onProxyLoad (http://192.10.0.10/website/var/tmp/minified_javascript_core_f5757da9fa29d5bf13e6aa5058eff9f7.js?_dc=3708:5641:28)
at Ext.cmd.derive.triggerCallbacks (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:594533)
at Ext.cmd.derive.setCompleted (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:594231)
at Ext.cmd.derive.setException (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:594444)
at Ext.cmd.derive.process (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:593638)
at Ext.cmd.derive.processResponse (http://192.10.0.10/pimcore/static6/js/lib/ext/ext-all.js?_dc=3708:22:648303)
Just reinstall Pimcore.
It can be some composer or submodules error.
I strongly recommend for the first installation to run Demo project https://github.com/pimcore/demo not Skeleton, especially if you are using Docker. Later, when you will get the feeling of Pimcore, feel free to install Skeleton or any other project.
Pimcore is stable working for years. If you had some problems before -- nowadays, it is stable.
I am trying to connect XPagesJDBC.nsf to a simple MS Access database,
it connects Successfully and i am able to perform the #JdbcInsert , Update, Delete. also able to execute SQL Query operations.
But i am facing an issue while trying to showing data in ViewPanel control with JDBC Query datasource type.
It give bellow error
Error while reading the relational data
Invalid Fetch Size
and a long StackTrace, i am copying some part of stack trace bellow;
I think this error is specific to MS Access, because i could find some successful implementation with other RDBMS also it work fine with "durby" at my end.
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:840)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)
com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)
com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)
com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)
com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1267)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1251)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
java.sql.SQLException: Invalid Fetch Size
sun.jdbc.odbc.JdbcOdbcStatement.setFetchSize(JdbcOdbcStatement.java:838)
sun.jdbc.odbc.JdbcOdbcResultSet.setFetchSize(JdbcOdbcResultSet.java:2987)
com.ibm.xsp.extlib.jdbc.model.JdbcDataBlockAccessor.loadBlock(JdbcDataBlockAccessor.java:389)
com.ibm.xsp.extlib.model.DataBlockAccessor.findBlockByIndex(DataBlockAccessor.java:344)
com.ibm.xsp.extlib.model.DataBlockAccessor.prefetchData(DataBlockAccessor.java:292)
com.ibm.xsp.extlib.model.DataAccessorModel.getRowCount(DataAccessorModel.java:93)
com.ibm.xsp.component.UIPager$PagerState.<init>(UIPager.java:76)
com.ibm.xsp.component.UIPager$PagerState.<init>(UIPager.java:71)
com.ibm.xsp.component.UIPager.createPagerState(UIPager.java:540)
com.ibm.xsp.renderkit.html_extended.XPagerRenderer.encodeChildren(XPagerRenderer.java:67)
com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeChildren(ReadOnlyAdapterRenderer.java:162)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:979)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:842)
com.ibm.xsp.renderkit.html_extended.ViewPanelRenderer.processPagerCell(ViewPanelRenderer.java:656)
com.ibm.xsp.renderkit.html_extended.ViewPanelRenderer.encodeBegin(ViewPanelRenderer.java:354)
com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeBegin(ReadOnlyAdapterRenderer.java:146)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:956)
javax.faces.component.UIData.encodeBegin(UIData.java:788)
com.ibm.xsp.component.UIDataEx.encodeBegin(UIDataEx.java:413)
com.ibm.xsp.component.UIViewPanel.encodeBegin(UIViewPanel.java:288)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:840)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)
myconnection.jdbc file ; ext_db is a DSN
<jdbc>
<driver>sun.jdbc.odbc.JdbcOdbcDriver</driver>
<url>jdbc:odbc:ext_db</url>
<user>xxx</user>
<password>xxx</password>
</jdbc>
The tongue-in-cheek-answer: get a database :-)
The problem seems to be well known and plagues others too to quite some extend. The batch-size parameter (first link) might work. You also could revisit your requirements. Would DECS do the trick?