| |

VerySource

 Forgot password?
 Register
Search
View: 936|Reply: 8

Some questions are simple, but how can I not figure it out (Hibernate buffer pool)

[Copy link]

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-15 15:00:01
| Show all posts |Read mode
I encountered such a problem: (I want to learn Struts + Hibernate to develop something. When I developed Struts with Jbuilder2005, I used JNDI + Server8083.xml + Oracle for the connection pool. But I used Eclipse + Myeclipse. I do n’t know how to start to configure the connection pool.) I searched the Internet for a long time and got some information-I can configure it in Hibernate first, but I wo n’t do it for a long time.
So my brother ’s requirements are: 1. I hope you can give me pointers on how to figure out the connection pool in Hibernate (you can do it without JNDI). The code is better, haha.
3, I hope that this post is not polite, just talk and type a few words.
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-25 23:54:01
| Show all posts
Based on another day of thinking, I will talk about my current method: 1. I built a Listener to set jndi
public void contextInitialized (ServletContextEvent sce)
    {
        ServletContext application = sce.getServletContext ();
        Context env = null;

        / **
         * Get the JNDI and set pool to a atrribute
         * Which we can use it in everywhere.
         * /

        try
        {
            env = (Context) new InitialContext (). lookup ("java: comp / env");
            ds = (DataSource) env.lookup ("jdbc / oracle / message_project");

            if (ds == null)
            {
                application.log ("Can not find jdbc / oracle / message_project JNDI");
            }
        }
        catch (NamingException ne)
        {
            application.log ("Can not get jdbc / oracle / message_project JNDI");
        }
        application.setAttribute ("ds", ds);
    }
  2, and then configure the database connection pool in tomcat5.0
<!-Here's what I added->
        <Resource name = "jdbc / oracle / message_project"
               auth = "Container"
               type = "javax.sql.DataSource" />
         <ResourceParams name = "jdbc / oracle / message_project">
    <parameter>
      <name> factory </ name>
      <value> org.apache.commons.dbcp.BasicDataSourceFactory </ value>
    </ parameter>

    <!-Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         ->
    <parameter>
      <name> maxActive </ name>
      <value> 100 </ value>
    </ parameter>

    <!-Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit. See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         ->
    <parameter>
      <name> maxIdle </ name>
      <value> 30 </ value>
    </ parameter>

    <!-Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded. Set to -1 to wait indefinitely.
         ->
    <parameter>
      <name> maxWait </ name>
      <value> 10000 </ value>
    </ parameter>

    <!-MySQL dB username and password for dB connections->
    <parameter>
     <name> username </ name>
     <value> System </ value>
    </ parameter>
    <parameter>
     <name> password </ name>
     <value> sql </ value>
    </ parameter>

    <!-Class name for the old mm.mysql JDBC driver-uncomment this entry and comment next
         if you want to use this driver-we recommend using Connector / J though
    <parameter>
       <name> driverClassName </ name>
       <value> org.gjt.mm.mysql.Driver </ value>
    </ parameter>
     ->
    
    <!-Class name for the official MySQL Connector / J driver->
    <parameter>
       <name> driverClassName </ name>
       <value> oracle.jdbc.driver.OracleDriver </ value>
    </ parameter>
    
    <!-The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect = true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
         connection. mysqld by default closes idle connections after 8 hours.
         ->
    <parameter>
      <name> url </ name>
      <value> jdbc: oracle: thin: @localhost: 1521: admin06 </ value>
    </ parameter>
  </ ResourceParams>
    <!-I added the above->
Problems: 1. I do n’t know if it ’s right or not 2. (I use eclipse + myeclipse) I ca n’t find the database mapping in myeclipse ) Why can't I find it with jndi, of course I know it but I don't know. So I hope you have no pity for your advice. I have been waiting online for a day and a night. .
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-1 11:15:01
| Show all posts
You can configure a database connection JDBC directly in myeclipse database
The connection of JNDI has not been configured in myeclipse, and the configuration in TOMCAT alone makes it clear upstairs!
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-28 12:15:01
| Show all posts
Hehe, thank you for your speech upstairs, I have to temporarily use direct configuration for the time being. Because I really do not know how to use jndi to match. .
I hope any brother or sister can teach me
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-3 22:45:01
| Show all posts
Add in hibernate.cfg.xml:
<property name = "jdbc.batch_size"> 5 </ property>
<!-Database connection settings->
<property name = "hibernate.connection.provider_class"> org.hibernate.connection.ProxoolConnectionProvider </ property>
<property name = "hibernate.proxool.pool_alias"> DBPool </ property>
<property name = "hibernate.proxool.xml"> Proxool.xml </ property>
<!-SQL dialect->
<property name = "dialect"> org.hibernate.dialect.Oracle9Dialect </ property>
<!-Echo all executed SQL to stdout->
<property name = "show_sql"> true </ property>
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-4 01:00:02
| Show all posts
Then build a separate xml file Proxool.xml
<? xml version = "1.0" encoding = "UTF-8"?>
<!-the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored.->
<something-else-entirely>
<proxool>
<alias> DBPool </ alias>
<driver-url>
jdbc: oracle: thin: @ 127.0.0.1: 1521: edudb
</ driver-url>
<driver-class> oracle.jdbc.driver.OracleDriver </ driver-class>
<driver-properties>
<property name = "user" value = "crmweb" />
<property name = "password" value = "crmweb" />
</ driver-properties>
<connection-lifetime> 60 </ connection-lifetime>
<maximum-connection-count> 20 </ maximum-connection-count>
<minimum-connection-count> 4 </ minimum-connection-count>
<house-keeping-test-sql>
select CURRENT_DATE
</ house-keeping-test-sql>
</ proxool>
</ something-else-entirely>
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-27 18:00:01
| Show all posts
Thanks, I want to ask this question: HTTP Status 500-

-------------------------------------------------- ------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
org.apache.jasper.runtime.PageContextImpl.doHandlePageException (PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException (PageContextImpl.java:758)
org.apache.jsp.login_005fmessage.login_jsp._jspService (login_jsp.java:169)
org.apache.jasper.runtime.HttpJspBase.service (HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service (JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service (JspServlet.java:236)
javax.servlet.http.HttpServlet.service (HttpServlet.java:802)

What's the problem, how can't I find it: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope, I really don't understand it. After a long time, it was sweating and raining in winter. . .
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-28 08:30:01
| Show all posts
loginContent.jsp:
<html: form action = "/ login">
<table>
<tr>
<td>
<bean: message key = "login.name" />
</ td>
<td>
<html: text property = "userName" />
<html: errors property = "name" />
</ td>
</ tr>
<tr>
<td>
<bean: message key = "login.pwd" />
</ td>
<td>
<html: password property = "userPassword" />
<html: errors property = "password" />
</ td>
</ tr>
The
<tr>
<td>
<html: submit property = "submit">
<bean: message key = "login.submit" />
</ html: submit>
</ td>
<td>
<html: reset property = "reset">
<bean: message key = "login.reset" />
</ html: reset>
</ td>
</ tr>
</ table>
</ html: form>
login.jsp:
<% @ include file = "../ taglibs.jsp"%>
<!-?? head.jsp? left.jsp? footer.jsp ???->
<html>
<head>
<title> JSP for loginForm form </ title>
</ head>
<body>
<% @ include file = "loginContent.jsp"%>
</ body>
</ html>
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-30 14:45:01
| Show all posts
Strange thing, I merged the two pages together and it was ok. This struts is really a headache. It seems that it is necessary to figure out its label.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list