package ;
import com.skittles.haxe.util.DataBaseUtil;
class Application { public static function main() { var db_connection : sys.db.Connection = com.skittles.haxe.util.DataBaseUtil.getDBConnection(); } }
package com.skittles.haxe.util;
class DatabaseUtil{ private static var db_connection : sys.db.Connection;
/** * Checks if database connection is opened. * If not, then tries to open it. */ private static function databaseConnectionAvailable() { if (db_connection != null) { return true; } else { try { db_connection = sys.db.Mysql.connect( { host : "localhost", port : 8889, user : "root", pass : "root", socket : null, database : "skittles" });
return true; } catch ( e:sys.db.Object) { return false; } } }
public static function getDBConnection() : sys.db.Connection { if( databaseConnectionAvailable() ) { return db_connection; } return null; }}
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.