Hi,
Does anyone know if it would be possible to connect to the database from Jetty using JSP page, by referring to zone settings somehow ?
We have Jetty acting as a load balancer and would like it if we can make quick connections to the database to check a parameter, is this possible ?
Thanks
Connecting to the database from JSP page
Re: Connecting to the database from JSP page
Yes, there should be no problem.
You should be able to obtain a reference to SmartFox via this line:
From there you can access the Zone:
and finally the DBManager object:
hope it helps
You should be able to obtain a reference to SmartFox via this line:
Code: Select all
SmartFox sfs = SmartFoxServer.getInstance();
From there you can access the Zone:
Code: Select all
Zone myZone = sfs.getZoneManager().getZoneByName("myZone");
and finally the DBManager object:
Code: Select all
IDBManager db = myZone.getDBManager();
hope it helps
Re: Connecting to the database from JSP page
Fantastic! Thank you
Re: Connecting to the database from JSP page
How can the JSP load the SFS classes ?
Getting an error even with importing the relevant classes :
Getting an error even with importing the relevant classes :
Code: Select all
<%@ page import="com.smartfoxserver.v2.SmartFoxServer,com.smartfoxserver.v2.entities.SFSZone,com.smartfoxserver.v2.db.SFSDBManager" %>
<%
SmartFox sfs = SmartFoxServer.getInstance();
Zone myZone = sfs.getZoneManager().getZoneByName("myZone");
IDBManager db = myZone.getDBManager();
%>
Caused by:
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
PWC6197: An error occurred at line: 5 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
SmartFox cannot be resolved to a type
PWC6197: An error occurred at line: 5 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
Zone cannot be resolved to a type
PWC6197: An error occurred at line: 5 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
IDBManager cannot be resolved to a type
Re: Connecting to the database from JSP page
Ok I figured out the problem - need to use SmartFoxServer, I don't think SmartFox exists as a class definition ?
This solved the issue:
This solved the issue:
Code: Select all
<%@ page import="com.smartfoxserver.v2.*,com.smartfoxserver.v2.entities.*,com.smartfoxserver.v2.db.*" %>
Re: Connecting to the database from JSP page
No, there is no such class as SmartFox. The name is SmartFoxServer.
Who is online
Users browsing this forum: Google [Bot] and 53 guests