// Generated by Haxe 4.3.1
package sys.db;

import haxe.root.*;

@SuppressWarnings(value={"rawtypes", "unchecked"})
public class Mysql extends haxe.lang.HxObject
{
	static
	{
		//line 26 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
		sys.db.Mysql.init = false;
	}
	
	public Mysql(haxe.lang.EmptyObject empty)
	{
	}
	
	
	public Mysql()
	{
		//line 25 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
		sys.db.Mysql.__hx_ctor_sys_db_Mysql(this);
	}
	
	
	protected static void __hx_ctor_sys_db_Mysql(sys.db.Mysql __hx_this)
	{
	}
	
	
	public static boolean init;
	
	public static sys.db.Connection connect(java.lang.Object params)
	{
		//line 35 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
		try 
		{
			//line 36 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			if ( ! (sys.db.Mysql.init) ) 
			{
				//line 37 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				java.lang.Class.forName(haxe.lang.Runtime.toString("com.mysql.jdbc.Driver"));
				//line 38 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				sys.db.Mysql.init = true;
			}
			
			//line 40 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			haxe.root.StringBuf url = new haxe.root.StringBuf();
			//line 41 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			url.add(haxe.lang.Runtime.toString("jdbc:mysql:"));
			//line 41 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
			//line 42 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			if (( haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "socket", true)) != null )) 
			{
				//line 43 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				url.add(haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "socket", true)));
				//line 43 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				java.lang.Object __temp_expr5 = ((java.lang.Object) (null) );
			}
			else
			{
				//line 45 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				url.add(haxe.lang.Runtime.toString("//"));
				//line 45 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
				//line 46 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				url.add(haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "host", true)));
				//line 46 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				java.lang.Object __temp_expr3 = ((java.lang.Object) (null) );
				//line 47 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				if (( ! (haxe.lang.Runtime.eq(haxe.lang.Runtime.getField(params, "port", true), null)) )) 
				{
					//line 48 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
					url.add(haxe.lang.Runtime.toString(( haxe.lang.Runtime.toString(":") + haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "port", true)) )));
					//line 48 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
					java.lang.Object __temp_expr4 = ((java.lang.Object) (null) );
				}
				
			}
			
			//line 50 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			if (( haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "database", true)) != null )) 
			{
				//line 51 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				url.add(haxe.lang.Runtime.toString(( "/" + haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "database", true)) )));
				//line 51 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
				java.lang.Object __temp_expr6 = ((java.lang.Object) (null) );
			}
			
			//line 53 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			java.sql.Connection cnx = java.sql.DriverManager.getConnection(haxe.lang.Runtime.toString(url.toString()), haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "user", true)), haxe.lang.Runtime.toString(haxe.lang.Runtime.getField(params, "pass", true)));
			//line 54 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			return haxe.java.db.Jdbc.create(cnx);
		}
		catch (java.lang.Throwable typedException)
		{
			//line 35 "/usr/share/haxe/std/java/_std/sys/db/Mysql.hx"
			throw ((java.lang.RuntimeException) (haxe.Exception.thrown(typedException)) );
		}
		
		
	}
	
	
}


