예제 #1
0
        public static void start(String ip, String port, String databasename, String username, String password, int type)
        {
            DBType databasetype = DBType.CubridDB;

            dbfrom = new DBStringBuilder(databasetype, ip, port, databasename, username, password);

            //MessageBox.Show(type+"");
            try
            {
                if (type == 1)
                {
                    csql = CubridSQLConnection.getConnection();
                    csql.connectionString = dbfrom;
                    MessageBox.Show(csql.OpenConnection() ? "erfolgreich" : "gescheitert");
                    cs = csql.getConn();
                }

                else if (type == 2)
                {
                    ms = MSSQLConnection.getConnection();
                    ms.connectionString = dbfrom;
                    MessageBox.Show(ms.OpenConnection() ? "erfolgreich" : "gescheitert");
                }
                else
                {
                    // os.CloseConnection();
                    os = OracleSQLConnection.getConnection();
                    os.connectionString = dbfrom;
                    MessageBox.Show(os.OpenConnection() ? "erfolgreich" : "gescheitert");
                }
                Console.Out.WriteLine(dbfrom.ToString());
            }
            catch (Exception e)
            {
                if (e.Message.Contains("Failed to connect to"))
                {
                    MessageBox.Show("Invalid Databasename");
                }
                else if (e.Message.Contains("Cannot connect to"))
                {
                    MessageBox.Show("Invalid port or address");
                }
                else if (e.Message.Contains("password"))
                {
                    MessageBox.Show("Invalid password");
                }
                else if (e.Message.Contains("User"))
                {
                    MessageBox.Show("Invalid username");
                }

                else
                {
                    MessageBox.Show("An unexpected error occured");
                    // MessageBox.Show(e.ToString());
                }

                close();
            }
        }
예제 #2
0
        public void testSequence()
        {
            DBStringBuilder mssqlconnecitonString = new DBStringBuilder(DBType.MSSQL, "84.115.153.150", "1433", "testdb", "SA", "Migrate01");

            MSSQLConnection mssql = MSSQLConnection.getConnection();

            mssql.connectionString = mssqlconnecitonString;
            mssql.OpenConnection();
            Sequence sequence = mssql.GetSequences()[0];

            Console.Out.WriteLine(sequence.ToString());
        }
예제 #3
0
        public void testViews()
        {
            DBStringBuilder     oracleSQL = new DBStringBuilder(DBType.OracleSQL, "db2.htl-kaindorf.at", "1521", "", "hofmad16", "Manuelh0");
            OracleSQLConnection oracleS   = OracleSQLConnection.getConnection();

            oracleS.connectionString = oracleSQL;
            oracleS.OpenConnection();
            List <ConstraintInfo> llist = oracleS.getConstraintsFromTable("EMP");

            foreach (ConstraintInfo l in llist)
            {
                Console.Out.WriteLine(l.constraintName + ", " + l.Condition + ", " + l.constraintType.ToString());
            }

            oracleS.CloseConnection();
        }