diff --git a/lib/setup.php b/lib/setup.php
index e73ba6cdf4ff04c991b804ec61464218d8eab73d..11c6cc76b66bfdc4bf7ac15c0f72fdc6c202f35f 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -19,6 +19,14 @@ class DatabaseSetupException extends Exception
 }
 
 class OC_Setup {
+	static $db_setup_classes = array(
+		'mysql' => '\OC\Setup\MySQL',
+		'pgsql' => '\OC\Setup\PostgreSQL',
+		'oci'   => '\OC\Setup\OCI',
+		'mssql' => '\OC\Setup\MSSQL',
+		'sqlite' => '\OC\Setup\Sqlite',
+		'sqlite3' => '\OC\Setup\Sqlite',
+	);
 
 	public static function getTrans(){
 		return OC_L10N::get('lib');
@@ -40,31 +48,14 @@ class OC_Setup {
 			$options['directory'] = OC::$SERVERROOT."/data";
 		}
 
-		if($dbtype == 'mysql' or $dbtype == 'pgsql' or $dbtype == 'oci' or $dbtype == 'mssql') { // these needs more config options
-			if($dbtype == 'mysql')
-				$dbprettyname = 'MySQL';
-			else if($dbtype == 'pgsql')
-				$dbprettyname = 'PostgreSQL';
-			else if ($dbtype == 'mssql')
-				$dbprettyname = 'MS SQL Server';
-			else
-				$dbprettyname = 'Oracle';
-
-
-			if(empty($options['dbuser'])) {
-				$error[] = $l->t("%s enter the database username.", array($dbprettyname));
-			}
-			if(empty($options['dbname'])) {
-				$error[] = $l->t("%s enter the database name.", array($dbprettyname));
-			}
-			if(substr_count($options['dbname'], '.') >= 1) {
-				$error[] = $l->t("%s you may not use dots in the database name", array($dbprettyname));
-			}
-			if($dbtype != 'oci' && empty($options['dbhost'])) {
-				$options['dbhost'] = 'localhost';
-			}
+		if (!isset(self::$db_setup_classes[$dbtype])) {
+			$dbtype = 'sqlite';
 		}
 
+		$class = self::$db_setup_classes[$dbtype];
+		$db_setup = new $class(self::getTrans());
+		$error = array_merge($error, $db_setup->validate($options));
+
 		if(count($error) != 0) {
 			return $error;
 		}
@@ -91,17 +82,8 @@ class OC_Setup {
 		OC_Config::setValue('datadirectory', $datadir);
 		OC_Config::setValue('dbtype', $dbtype);
 		OC_Config::setValue('version', implode('.', OC_Util::getVersion()));
-		$db_setup_classes = array(
-			'mysql' => '\OC\Setup\MySQL',
-			'pgsql' => '\OC\Setup\PostgreSQL',
-			'oci'   => '\OC\Setup\OCI',
-			'mssql' => '\OC\Setup\MSSQL',
-			'sqlite' => '\OC\Setup\Sqlite',
-			'sqlite3' => '\OC\Setup\Sqlite',
-		);
 		try {
-			$class = $db_setup_classes[$dbtype];
-			$db_setup = new $class(self::getTrans(), $options);
+			$db_setup->initialize($options);
 			$db_setup->setupDatabase($username);
 		} catch (DatabaseSetupException $e) {
 			$error[] = array(
diff --git a/lib/setup/abstractdatabase.php b/lib/setup/abstractdatabase.php
index cef64ee7ebbe9a4ed009d7e15ec8baf9ef248c7e..07a679f211227b9d0c4f58eb2655e1a4318ee219 100644
--- a/lib/setup/abstractdatabase.php
+++ b/lib/setup/abstractdatabase.php
@@ -12,14 +12,27 @@ abstract class AbstractDatabase {
 
 	public function __construct($trans, $config) {
 		$this->trans = $trans;
-		$this->initialize($config);
+	}
+
+	public function validate($config) {
+		$errors = array();
+		if(empty($config['dbuser'])) {
+			$errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
+		}
+		if(empty($config['dbname'])) {
+			$errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
+		}
+		if(substr_count($config['dbname'], '.') >= 1) {
+			$errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname));
+		}
+		return $errors;
 	}
 
 	public function initialize($config) {
 		$dbuser = $config['dbuser'];
 		$dbpass = $config['dbpass'];
 		$dbname = $config['dbname'];
-		$dbhost = isset($config['dbhost']) ? $config['dbhost'] : ''; // dbhost contents is checked earlier
+		$dbhost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
 		$dbtableprefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
 
 		\OC_Config::setValue('dbname', $dbname);
diff --git a/lib/setup/mssql.php b/lib/setup/mssql.php
index a1414a9ac573fd2a6d56090fd2e613bf9e2f92b1..74ac8f294a9817c9a7667910f1c3c1e736aaa357 100644
--- a/lib/setup/mssql.php
+++ b/lib/setup/mssql.php
@@ -3,6 +3,8 @@
 namespace OC\Setup;
 
 class MSSQL extends AbstractDatabase {
+	public $dbprettyname = 'MS SQL Server';
+
 	public function setupDatabase() {
 		//check if the database user has admin right
 		$masterConnectionInfo = array( "Database" => "master", "UID" => $this->dbuser, "PWD" => $this->dbpassword);
diff --git a/lib/setup/mysql.php b/lib/setup/mysql.php
index 790b8e82257d9d6b8e1914fbdfaa006fcd1958cf..aa0344f686ccfc7628d26e63197fd39d70206c34 100644
--- a/lib/setup/mysql.php
+++ b/lib/setup/mysql.php
@@ -3,6 +3,8 @@
 namespace OC\Setup;
 
 class MySQL extends AbstractDatabase {
+	public $dbprettyname = 'MySQL';
+
 	public function setupDatabase($username) {
 		//check if the database user has admin right
 		$connection = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword);
diff --git a/lib/setup/oci.php b/lib/setup/oci.php
index 3bb625c557d3f426b843a04166c5809b6deb3b4b..a3e2ccc8da7cc37db04113265950c18327676b41 100644
--- a/lib/setup/oci.php
+++ b/lib/setup/oci.php
@@ -3,6 +3,8 @@
 namespace OC\Setup;
 
 class OCI extends AbstractDatabase {
+	public $dbprettyname = 'Oracle';
+
 	protected $dbtablespace;
 
 	public function initialize($config) {
diff --git a/lib/setup/postgresql.php b/lib/setup/postgresql.php
index 3fb1e6b878768da05cadcc5d271c139c8eb425b3..67e4f901a9191ab53abdd17d639ad7fec4921120 100644
--- a/lib/setup/postgresql.php
+++ b/lib/setup/postgresql.php
@@ -3,6 +3,8 @@
 namespace OC\Setup;
 
 class PostgreSQL extends AbstractDatabase {
+	public $dbprettyname = 'PostgreSQL';
+
 	public function setupDatabase($username) {
 		$e_host = addslashes($this->dbhost);
 		$e_user = addslashes($this->dbuser);
diff --git a/lib/setup/sqlite.php b/lib/setup/sqlite.php
index b1785ce1b0bdce6bf7415efae05aaad1a2f03911..0b96ec6000930dab5cbc265c44c8258dcdb95774 100644
--- a/lib/setup/sqlite.php
+++ b/lib/setup/sqlite.php
@@ -3,6 +3,11 @@
 namespace OC\Setup;
 
 class Sqlite extends AbstractDatabase {
+	public $dbprettyname = 'Sqlite';
+
+	public function validate($config) {
+	}
+
 	public function initialize($config) {
 	}