New topic: RB error when connecting to MySQL
<http://forums.realsoftware.com/viewtopic.php?t=46430> Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message BrunoFrechette Post subject: RB error when connecting to MySQLPosted: Thu Jan 03, 2013 11:25 pm Joined: Fri Jan 12, 2007 10:59 am Posts: 136 Location: Victoriaville, QC, Canada Hi all. Got a strange behaviour that I found a workaround for. I'd like to see if anyone has seen this or can enlighten me on the matter. I'm building a web app with a MySQL server as a backend. Developing on OSX 10.7.5 with RS2012r2. In the Session.open event, I initiate the connection to the database. I have a db property in the session object to store a database connection for each user. I also have a bunch of constants for the db connection info. Here's the session.open code: db = new MySQLCommunityServer db.Host = kDBIPDebug db.DatabaseName = kdbName db.UserName = kdbUsername db.Password = kdbPassword 'try to connect if db.Connect = false then ErrorWIn.Message = "We're having difficulties. Try again later." // this is a property in the error window DisconnectError // this method cleans-up and shows the error window return end if 'success! set character encoding so we don't get funny stuff with accents db.SQLExecute ("SET NAMES 'utf8' ; SET CHARACTER_SET 'utf8' ; SET collation_connection = utf8_general_ci") Now here's the fun part. When I run the app in the IDE, about one time out of 6 I get the RealStudio error "This application has encountered a problem" with the web page showing the "starting up" icon and progress bar. The IDE hilites the db.SQLExecute statement, but I don't have any error in the IDE. All's fine, no error on the db object. What I did that seems to completely solve the problem is to put the db.SQLExecute statement in the open event of the first page displayed. And now, no more error. I started the app 20 times with no error. I rinsed and repeated the process a few times, switching the statement back and forth and got the consistent results: error when it's right after the connect statement, no error when it's in the window.open event. Now I'm working from home and the database is at the office and accessed through a VPN connection (for developing and testing) so it might be a 'timeout' of some kind. But all other operations on the site work like a charm with no internal error whatsoever. So could it be that the initial connection times-out on RB and you get that error? I haven't thoroughly tested it with compiled or cgi apps, nor with the app installed in the office (closer to the db). But suffice to say that I can reproduce the problem consistently with my current setup, which leads me to write myself a mental note: don't perform a query right after the connect statement! .. and maybe it'll save some head-banging sessions for others! (any comment appreciated) _________________ Bruno Fréchette PJJ Productions inc. RealStudio Web & Desktop on OSX Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 1 post ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
