Bug 250300

Summary: MySQL Connection problem
Product: [Applications] kmymoney Reporter: Tom Spuhler <thomas>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: major CC: fvilas, leo, martin, tonyb.sfkde
Priority: NOR    
Version: 4.5   
Target Milestone: ---   
Platform: Mandriva RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: connection window
See result in the attachement
New crash information added by DrKonqi

Description Tom Spuhler 2010-09-05 19:50:51 UTC
Version:           4.5 (using KDE 4.5.0) 
OS:                Linux

I setup a new KMyMoney and using MSQL as database. When restarting, it shows me the connection window and asks for a password. All fields look correct, such as database, username and of course I enter the password.I get an error that connection failed.(and the program crashes. Yes the database section crashes a lot)
I restart the program and cancel every window that comes up, I get the connection error as expected, I cancel and after everything looks clear, I go to file -> open database. then the same window opens as initially with the same info in it. I enter the same password as initially and I get the connection and the data show up.


Reproducible: Always

Steps to Reproduce:
I restart the program and cancel every window that comes up, I get the connection error as expected, I cancel and after everything looks clear, I go to file -> open database. then the same window opens as initially with the same info in it. I enter the same password as initially and I get the connection and the data show up.
Comment 1 Tony B 2010-09-06 10:12:20 UTC
How did you create the database? If you allowed KMM to create it for you, you should not need to enter a password. This is covered in the Help pages (I think!).

Otherwise, could you start KMM from within a konsole session, and let us know what error message you see?
Comment 2 Tom Spuhler 2010-09-06 17:11:37 UTC
It looks like it's not using the database

$ kmymoney 
kmymoney(18788)/kdecore (KPluginInfo) KPluginInfo::kcmServices: found  0  offers for  "KBanking"
kmymoney(18788)/kdecore (KPluginInfo) KPluginInfo::kcmServices: found  0  offers for  "Reconciliation report"
kmymoney(18788)/kdecore (KPluginInfo) KPluginInfo::kcmServices: found  1  offers for  "Print check"
kmymoney(18788)/kdecore (KPluginInfo) KPluginInfo::kcmServices: found  0  offers for  "KMyMoney OFX"
kmymoney(18788)/kdecore (KPluginInfo) KPluginInfo::kcmServices: found  1  offers for  "iCalendar"
kmymoney(18788)/kdecore (KLibrary) kde4Factory: The library "/usr/lib64/kde4/kmm_kbanking.so" does not offer a qt_plugin_instance function.
7:2010/09/06 08-06-40:aqbanking(18788):started
3:2010/09/06 08-06-40:aqbanking(18788):qbanking.cpp:  422: No Qt translation found for your language en
KMyMoney kbanking plugin loaded
kmymoney(18788)/kdecore (KLibrary) kde4Factory: The library "/usr/lib64/kde4/kmm_reconciliationreport.so" does not offer a qt_plugin_instance function.
KMyMoney reconciliation report plugin loaded
Calling appendChild() on a null node does nothing.
kmymoney(18788)/kdecore (KLibrary) kde4Factory: The library "/usr/lib64/kde4/kmm_printcheck.so" does not offer a qt_plugin_instance function.
KMyMoney printcheck plugin loaded
kmymoney(18788)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
QFSFileEngine::open: No file name specified
kmymoney(18788)/kdecore (KLibrary) kde4Factory: The library "/usr/lib64/kde4/kmm_ofximport.so" does not offer a qt_plugin_instance function.
KMyMoney ofximport plugin loaded
kmymoney(18788)/kdecore (KLibrary) kde4Factory: The library "/usr/lib64/kde4/kmm_icalendarexport.so" does not offer a qt_plugin_instance function.
KMyMoney iCalendar plugin loaded
QPainter::end: Painter ended with 2 saved states
QPainter::end: Painter ended with 2 saved states
QPainter::end: Painter ended with 2 saved states
QPainter::end: Painter ended with 2 saved states
QPainter::end: Painter ended with 2 saved states
Error in function int MyMoneyStorageSql::upgradeDb() : Error retrieving file info(version)
Driver = QMYSQL, Host = localhost, User = thomas, Database = 
Driver Error: 
Database Error No -1: 
Text:  
Error type 0
Executed: SELECT version FROM kmmFileInfo;
Query error No 1046: No database selected QMYSQL: Unable to execute query                                                    
Error type 2                                                                                                                 
KCrash: Application 'kmymoney' crashing...                                                                                   
sock_file=/home/thomas/.kde4/socket-xxxxxx.btspuhler.com/kdeinit4__0                                                         
                                                                                                                             
[1]+  Stopped                 kmymoney
Comment 3 Tom Spuhler 2010-09-06 17:12:54 UTC
Created attachment 51366 [details]
connection window
Comment 4 Fernando Vilas 2010-09-07 03:40:25 UTC
Somehow the database name is not getting set, even though it is there in the screenshot. 

I also updated the bug title, since MSQL is the driver for Microsoft SQL Server, and you appear to be using MySQL.
Comment 5 Tony B 2010-09-07 10:54:03 UTC
Thomas. Can you try starting KMM with the following line and see what happens?

sql://thomas@localhost/KMyMoney?driver=QMYSQL

Technical bit. The database name is taken from the url passed to mmstoragesql. If that's blank, I would expect it to fail to open the database. Instead it's failing later, in trying to upgrade. Something strange here.
Comment 6 Tom Spuhler 2010-09-08 02:48:33 UTC
Something must be wrong in this command:
$ sql://thomas@localhost/KMyMoney?driver=QMYSQL
bash: sql://thomas@localhost/KMyMoney?driver=QMYSQL: No such file or directory
Comment 7 Fernando Vilas 2010-09-08 03:24:03 UTC
The command should be 
$ kmymoney sql://thomas@localhost/KMyMoney?driver=QMYSQL
Comment 8 Tom Spuhler 2010-09-09 03:00:53 UTC
Created attachment 51446 [details]
See result in the attachement
Comment 9 Tony B 2010-09-09 10:54:09 UTC
One of two things, either you didn't give user thomas permissions on the database, or mysql requires a password for user thomas. Try the following:

1. in Konsole:
mysql -u root (you may need to supply a mysql root password if you set one up)
grant all on KMyMoney.* to thomas@localhost;
flush privileges;
quit;
See if that helps. Or

2. Start kmymoney with
kmymoney sql://thomas@localhost/KMyMoney?driver=QMYSQL&secure=yes
You will then need to supply your mysql password in the resulting dialog.

Note you should not confuse the mysql password for thomas with your Linux login password; it may be the same, it may not, depending on how you set it up.
Comment 10 Tom Spuhler 2010-09-09 16:24:34 UTC
This command is missing something. I am not being asked for a password. already have granted ALL to the database. I can connect from KmyMoney if I open if from within.
 Access denied for user 'thomas'@'localhost' (using password: NO)
Comment 11 Tony B 2010-09-12 17:27:11 UTC
Part of the problem here lies in the pseudo-URL we use. Where you have a passworded database, the URL contains an ampersand (&) character. This is now being interpreted, correctly I suspect, as the end of the command, hence the following 'secure=yes', which indicates a password is needed, is getting dropped. Try enclosing the URL in single quotes as follows:

kmymoney 'sql://thomas@localhost/KMyMoney?driver=QMYSQL&secure=yes'

I need to look at how we handle the matter of the recent files list.
Comment 12 Tom Spuhler 2010-09-12 19:34:08 UTC
I am now asked for a password, but from the error message, it looks as if teh database name is now being dropped:
Error in function int MyMoneyStorageSql::upgradeDb() : Error retrieving file info(version)
Driver = QMYSQL, Host = localhost, User = thomas, Database = 
Driver Error: 
Database Error No -1: 
Text:  
Error type 0
Executed: SELECT version FROM kmmFileInfo;
Query error No 1046: No database selected QMYSQL: Unable to execute query
Error type 2
Comment 13 Tom Spuhler 2010-09-12 19:41:29 UTC
This is the same error as when I start KMyMoney from the menu. I looks as if the database name gets lost.
BTW I am currently on IRC freenode mandriva
Comment 14 Fernando Vilas 2010-09-14 04:27:42 UTC
SVN commit 1175070 by fvilas:

BUG: 250300

Commit Tony Bloomfield's patch to fix database name being dropped when a password is used for database logins.



 M  +1 -0      kselectdatabasedlg.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1175070
Comment 15 Tom Spuhler 2010-09-14 06:51:57 UTC
seems to work. I applied it in Mandriva, 2010.1 updates and cooker
Comment 16 Cristian Oneț 2010-12-08 12:58:14 UTC
*** Bug 249762 has been marked as a duplicate of this bug. ***
Comment 17 Josef Leo Bureš 2012-06-03 13:36:53 UTC
Created attachment 71536 [details]
New crash information added by DrKonqi

Error in function const QMap MyMoneyStorageSql::fetchBalance(const QStringList&, const QDate&) const : fetching balance Driver = QMYSQL, Host = localhost, User = kmymoney, Database = KMyMoney Driver Error: Database Error No -1: Text: Error type 0 Executed: SELECT action, shares, accountId, postDate FROM kmmSplits WHERE txType = 'N' AND accountId in) ORDER BY accountId, postDate; Query error No 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY accountId, postDate' at line 1 QMYSQL: Nelze vykonat dotaz Error type 2 in file /tmp/buildd/kmymoney-3.98.1/kmymoney/mymoney/storage/mymoneystoragesql.cpp line 2954
Comment 18 Fernando Vilas 2012-06-03 14:03:36 UTC
Git commit dfe65b2d1fc8d4ae196b7f5a6973024208f15f37 by Fernando Vilas.
Committed on 03/06/2012 at 16:02.
Pushed by fvilas into branch 'master'.

Ensure correct SQL syntax when the balance idList is empty.

M  +8    -4    kmymoney/mymoney/storage/mymoneystoragesql.cpp

http://commits.kde.org/kmymoney/dfe65b2d1fc8d4ae196b7f5a6973024208f15f37
Comment 19 Fernando Vilas 2012-06-03 14:06:03 UTC
Git commit 0d1d96938162f25d77f7ffae19773dbf807d7b7b by Fernando Vilas.
Committed on 03/06/2012 at 16:02.
Pushed by fvilas into branch '4.6'.

Ensure correct SQL syntax when the balance idList is empty.

M  +8    -4    kmymoney/mymoney/storage/mymoneystoragesql.cpp

http://commits.kde.org/kmymoney/0d1d96938162f25d77f7ffae19773dbf807d7b7b