Connecting to Database in all examples

27 views
Skip to first unread message

grant forrest

unread,
Oct 24, 2015, 9:09:44 PM10/24/15
to web4j-users
Hello - attempting to use the examples to get a feel for web4j.

Each example I try, I follow the instructions, setting all the configurations. However, I dont seem to be able to get a connection to my db.

My log file shows

Oct 25, 2015 12:35:18 AM hirondelle.web4j.Controller init
CONFIG: Calling ConnectionSource.init(ServletConfig).
Oct 25, 2015 12:35:18 AM hirondelle.web4j.config.ConnectionSrc init
CONFIG: Connection strings : (3) {
  'ACCESS_CONTROL' = 'java:comp/env/jdbc/fish_access'
  'DEFAULT' = 'java:comp/env/jdbc/fish'
  'TRANSLATION' = 'java:comp/env/jdbc/fish_translation'
}
Oct 25, 2015 12:35:18 AM hirondelle.web4j.Controller init
FINE: Init of internal classes, ConnectionSource completed 174.297 ms after start.
Oct 25, 2015 12:35:18 AM hirondelle.web4j.Controller tryDatabaseInitAndStartupTasks
CONFIG: Trying database init and startup tasks.
Oct 25, 2015 12:35:18 AM hirondelle.web4j.Controller tryDatabaseInitAndStartupTasks
CONFIG: Attempting data layer startup tasks.
Oct 25, 2015 12:36:34 AM hirondelle.web4j.database.DbConfig checkHealthOf
SEVERE: Cannot connect to database named 'DEFAULT'. Is database running?

It looks like it is not reading the fish.xml db connection strings:

<!-- Example of a Tomcat configuration file for this application. -->

<!-- The 'YOUR_MYSQL_...' items refer to a MySQL account. The given values are phony. Please change them. -->

<!-- Assumes MySQL is running on the default port 3306. Please change if necessary. -->

<!-- Maps a URL context under Tomcat to a location on your file system. Please change 'docBase': -->
<Context docBase="/Users/Forrest/Documents/fish" reloadable="true">

 <!-- How Tomcat should make Datasources, for the exclusive use of the application: -->
 <Resource 
   name="jdbc/fish" 
   auth="Container" 
   type="javax.sql.DataSource" 
   username="root"
   password="root"
   driverClassName="com.mysql.jdbc.Driver"
   maxActive="10"
   maxIdle="5"
 />
 <Resource 
   name="jdbc/fish_translation" 
   auth="Container" 
   type="javax.sql.DataSource" 
   username="root"
   password="root"
   driverClassName="com.mysql.jdbc.Driver"
   url="jdbc:mysql://192.168.52.10:3306/fish_translation"
   maxActive="10"
   maxIdle="5"
 />
 <Resource 
   name="jdbc/fish_access" 
   auth="Container" 
   type="javax.sql.DataSource" 
   username="root"
   password="root"
   driverClassName="com.mysql.jdbc.Driver"
   url="jdbc:mysql://192.168.52.10:3306/fish_access"
   maxActive="10"
   maxIdle="5"
 />


 <!-- How Tomcat should look for user names and passwords, when confirming end user credentials during login: -->
 <Realm 
  className="org.apache.catalina.realm.JDBCRealm" 
  connectionURL="jdbc:mysql://192.168.52.10:3306/fish_access"
  digest="SHA-1"
  driverName="com.mysql.jdbc.Driver"
  roleNameCol="Role"
  userCredCol="Password" 
  userNameCol="Name" 
  userRoleTable="UserRole" 
  userTable="Users" 
  connectionName="root"
  connectionPassword="root"
  debug="99"
 />
</Context>

I'm running a mac osx with a virtual machine running ubuntu server with mysql running. I normally run tomcat on the vm too, but for ease, I'm running that locally. 

I've read through the other forum posts, but no one seems to have had this issue .Any ideas?

Cheers

Grant

John O'Hanley

unread,
Oct 24, 2015, 9:19:11 PM10/24/15
to web4j-users
Yes, there's an issue connecting to the database.
 
This problem is usally resolved by checking all the settings very closely:
is the port correct?
is the db server running?
is the database driver jar visible to Tomcat?
try 'localhost' instead
are the credentials correct?
what if you run Tomcat on the VM too

If you're still having trouble, my only suggestion is to try the tutorial and the 'electricity' example app, which is more minimal. 

grant forrest

unread,
Oct 25, 2015, 1:49:04 PM10/25/15
to web4j-users
Hi John, 

Thanks for the quick reply, bit embarrassing, I had mistyped the IP address by one digit so that explains the lack of connectivity. Fresh eyes in the morning and a look over the settings I spotted the issue. 

Thanks again 
Reply all
Reply to author
Forward
0 new messages