Connection to secondary db

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
ekrem5353
Posts: 118
Joined: 10 Dec 2015, 15:50

Connection to secondary db

Postby ekrem5353 » 16 Feb 2017, 07:12

I am trying to connect to secondary mysql db I get this error :?

java.sql.SQLException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.sql.SQLException
Message: Cannot get a connection, pool error: Could not create a validated object, cause: ValidateObject failed
Description: The DBManager Test SQL failed: SELECT * from ayarlar
Please double check your SQL code and make sure that Database server is running.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

DBConfig cfg = new DBConfig();
cfg.active = true;
cfg.driverName = "com.mysql.jdbc.Driver";
cfg.connectionString = "jdbc:mysql://{path.mywebsite.com}/my_dbname?characterEncoding=UTF-8";
cfg.userName = "my_user";
cfg.password = "password";
cfg.testSql = "SELECT * from password";



webDBManager = new SFSDBManager(cfg);
//localDBManager.init(getParentZone());
webDBManager.init(null);

Actually before login we were using php code it was checking if user is registered user in the site. We thought smartfox should connect to the db and check. But I am getting this error. With same credentials php can connect to that db.

What might be the problem. Would it be wise to use regular jdbc connection ?

like this

//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");

//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);

//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = "SELECT id, first, last, age FROM Employees";
ResultSet rs = stmt.executeQuery(sql);





Thanks
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection to secondary db

Postby Lapo » 16 Feb 2017, 08:34

It looks like the test SQL isn't correct.
Is "password" actually the name of table inside your database?

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
ekrem5353
Posts: 118
Joined: 10 Dec 2015, 15:50

Re: Connection to secondary db

Postby ekrem5353 » 16 Feb 2017, 08:46

No I just trying to write dummy text it is SELECT * FROM ayarlar
User avatar
ekrem5353
Posts: 118
Joined: 10 Dec 2015, 15:50

Re: Connection to secondary db

Postby ekrem5353 » 16 Feb 2017, 10:02

Sorry it was my fault it was wrong table name in the test query
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Connection to secondary db

Postby Lapo » 16 Feb 2017, 11:32

So is it working now?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
ekrem5353
Posts: 118
Joined: 10 Dec 2015, 15:50

Re: Connection to secondary db

Postby ekrem5353 » 28 Mar 2017, 06:59

Yes it works

Thanks

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 102 guests