/** * Create a data provider. */ public static Database createDataProvider() { //<option name="db_system" value="mysql"/> string dbsystem=Configuration.getValue("db_system", "mysql"); switch(dbsystem.ToLower()) { case "sqlite": { //SQLite provider=new SQLite(); //return provider; return null; } case "mysql": { string host=Configuration.getValue("mysql_hostname", "example.org"); int port=Convert.ToInt32(Configuration.getValue("mysql_port", "3306")); string database=Configuration.getValue("mysql_database", ""); string username=Configuration.getValue("mysql_username", ""); string password=Configuration.getValue("mysql_password", ""); MySQL provider=new MySQL(host, port, database, username, password); return provider; } default: { throw new Exception(); } } }
static void Main(string[] args) { ////MySQL { Console.WriteLine("MySQL"); //Connect to MySQL Database string mySQLserver="seeseekey.net"; int mySQLPort=3306; string mySQLusername="******"; string mySQLpassword="******"; string mySQLDbName="daten"; MySQL mySQL=new MySQL(mySQLserver, mySQLPort, mySQLDbName, mySQLusername, mySQLpassword); mySQL.Connect(); //get table names List<string> tables=mySQL.GetTables(); foreach(string table in tables) { Console.WriteLine(table); } } ////PostgreSQL { Console.WriteLine("PostgreSQL"); //Connect to PostgreSQL Database string postgreSQLserver="seeseekey.net"; int postgreSQLPort=5432; string postgreSQLusername="******"; string postgreSQLpassword="******"; string postgreSQLDbName="test"; PostgreSQL postgresql=new PostgreSQL(postgreSQLserver, postgreSQLPort, postgreSQLDbName, postgreSQLusername, postgreSQLpassword); postgresql.Connect(); //get table names List<string> tables=postgresql.GetTables(); foreach(string table in tables) { Console.WriteLine(table); } } //SQLite { Console.WriteLine("SQLite"); //Connect/Open to SQlite Database string sqliteDB=@"D:\test.db"; SQLite sqlite=new SQLite(sqliteDB); //get table names List<string> tables=sqlite.GetTables(); foreach(string table in tables) { Console.WriteLine(table); } } //Ende Console.ReadLine(); }