[jboss-user] [JBoss Portal] - database issue

taocore do-not-reply at jboss.com
Sat Aug 16 05:37:21 EDT 2008


I am using my firebird database.
I create desktop.fdb under jboss-portal-2.6.6.GA\server\default\data\desktop, and create desktop-firebird-ds.xml under the deploy directory with the content:

  | <datasources>
  |   <local-tx-datasource>
  |     <jndi-name>DesktopDS</jndi-name>
  |     <connection-url>jdbc:firebirdsql:local:${jboss.server.data.dir}${/}desktop${/}desktop.fdb</connection-url>
  |     <driver-class>org.firebirdsql.jdbc.FBDriver</driver-class>
  |     <user-name>sysdba</user-name>
  |     <password><![CDATA[masterkey]]></password>
  |   </local-tx-datasource>
  | </datasources>
  | 
There is one table called computer_t with one record in desktop.fdb.
I have also placed the jaybird-full-2.1.6.jar under ${jboss_home}/server/default/lib

I changed the HelloWorldPortlet to show something in the database. The code is:

  | protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException
  |    {
  |       rResponse.setContentType("text/html");
  |       PrintWriter writer = rResponse.getWriter();
  |       writer.write("Hello World!\n");
  |       Connection conn = null;
  | 		try 
  | 		{
  | 			DataSource ds = (DataSource) new InitialContext().lookup("java:/DesktopDS");
  | 			System.out.println("1111111111111");
  | 			conn = ds.getConnection();
  | 			System.out.println("222222222222222");
  | 			String sql = "select * from computer_t";
  | 			PreparedStatement s = conn.prepareStatement(sql);
  | 			System.out.println("3333333333333333");
  | 			ResultSet rs = s.executeQuery();
  | 			System.out.println("4444444444444444444");
  | 			while (rs.next())
  | 			{
  | 				System.out.println("55555555555555555555");
  | 				String name = rs.getString(2);
  | 				writer.write(name + "\n");
  | 			}
  | 		} catch (NamingException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		} catch (SQLException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 		finally
  | 		{
  | 			if (conn != null)
  | 			{
  | 				try {
  | 					conn.close();
  | 				} catch (SQLException e) {
  | 					// TODO Auto-generated catch block
  | 					e.printStackTrace();
  | 				}
  | 			}
  | 		}
  |       writer.close();
  |    }
  | 

After deploying it and navigate the browser to the default page. I found no record shown in the portlet. The debug info was printed on the console 1, 2, 3, 4 but no 5.
After shut down the server, I use isql connect to the desktop.fdb, and found the record inserted before was lost.
It seems that the portal clear my table. Any suggestions?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170903#4170903

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170903



More information about the jboss-user mailing list