Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. 22:43:40,669 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) java.sql.SQLException: Error
  2. 22:43:40,669 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) at org.jboss.jca.adapters.jdbc.WrappedConnection.checkException(WrappedConnection.java:1643)
  3. 22:43:40,670 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) at org.jboss.jca.adapters.jdbc.WrappedStatement.checkException(WrappedStatement.java:1262)
  4. 22:43:40,670 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) at org.jboss.jca.adapters.jdbc.WrappedResultSet.checkException(WrappedResultSet.java:4063)
  5. 22:43:40,670 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) at org.jboss.jca.adapters.jdbc.WrappedResultSet.next(WrappedResultSet.java:1866)
  6. 22:43:40,671 ERROR [stderr] (http-localhost-127.0.0.1-8080-106) at fr.formation.dao.DaoImpl.getAllPersonnes(DaoImpl.java:275)
  7.  
  8. java.sql.SQLException: The result set is closed.
  9.  
  10. Caused by: java.lang.NullPointerException
  11. 22:43:40,992 ERROR [stderr] (http-localhost-127.0.0.1-8080-73) at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:825)
  12. 22:43:40,993 ERROR [stderr] (http-localhost-127.0.0.1-8080-73) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2710)
  13. 22:43:40,993 ERROR [stderr] (http-localhost-127.0.0.1-8080-73) at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2846)
  14. 22:43:40,993 ERROR [stderr] (http-localhost-127.0.0.1-8080-73) at org.jboss.jca.adapters.jdbc.WrappedResultSet.getInt(WrappedResultSet.java:1073)
  15. 22:43:40,993 ERROR [stderr] (http-localhost-127.0.0.1-8080-73) ... 23 more
  16. 22:43:40,993 ERROR [stderr] (http-localhost-127.0.0.1-8080-184) java.sql.SQLException: The result set is closed.
  17. 22:43:40,994 ERROR [stderr] (http-localhost-127.0.0.1-8080-184) at org.jboss.jca.adapters.jdbc.WrappedResultSet.checkState(WrappedResultSet.java:4081)
  18. 22:43:40,994 ERROR [stderr] (http-localhost-127.0.0.1-8080-184) at org.jboss.jca.adapters.jdbc.WrappedResultSet.getInt(WrappedResultSet.java:1065)
  19.  
  20. public List<PersonneDao> getAllPersonnes() throws SQLException{
  21. List<PersonneDao> liste = new ArrayList<PersonneDao>();
  22. ResultSet rs = null ;
  23. PreparedStatement preparedStatement = null;
  24. try {
  25.  
  26. connection = ConnectionUtil.getInstance().getConnection();
  27. preparedStatement = (PreparedStatement) connection.prepareStatement("select * from personne");
  28. rs = preparedStatement.executeQuery();
  29.  
  30.  
  31.  
  32. while (rs.next()) {
  33. PersonneDao user = new PersonneDao();
  34. user.setId (rs.getInt("id"));
  35. user.setNom (rs.getString("nom"));
  36. user.setPrenom(rs.getString("prenom"));
  37. user.setEmail(rs.getString("email"));
  38.  
  39. liste.add(user);
  40.  
  41. }
  42.  
  43. rs.close();
  44. } catch (SQLException e) {
  45. e.printStackTrace();
  46. }finally{
  47.  
  48. if (rs != null) {
  49. try {
  50. rs.close();
  51. } catch (SQLException sqlex) {
  52. // ignore, as we can't do anything about it here
  53. }
  54.  
  55. rs = null;
  56. }
  57.  
  58. if (preparedStatement != null) {
  59. try {
  60. preparedStatement.close();
  61. } catch (SQLException sqlex) {
  62. // ignore, as we can't do anything about it here
  63. }
  64.  
  65. preparedStatement = null;
  66. }
  67.  
  68. if (connection != null) {
  69. try {
  70. ConnectionUtil.getInstance().close(connection);
  71. } catch (SQLException sqlex) {
  72. // ignore, as we can't do anything about it here
  73. }
  74.  
  75. connection = null;
  76.  
  77.  
  78. }
  79. }
  80. return liste;
  81.  
  82. }
  83.  
  84. }
  85.  
  86. public class ConnectionUtil {
  87.  
  88. private DataSource dataSource;
  89.  
  90. private static ConnectionUtil instance = new ConnectionUtil();
  91.  
  92. private ConnectionUtil() {
  93. try {
  94. Context initContext = new InitialContext();
  95. dataSource = (DataSource) initContext.lookup("java:/dsFormationJSP");
  96. } catch (NamingException e) {
  97. e.printStackTrace();
  98. }
  99. }
  100.  
  101. public static ConnectionUtil getInstance() {
  102. return instance;
  103. }
  104.  
  105. public Connection getConnection() throws SQLException {
  106. Connection connection = dataSource.getConnection();
  107. return connection;
  108. }
  109.  
  110. public void close(Connection connection) throws SQLException {
  111. if (connection != null && !connection.isClosed()) {
  112. connection.close();
  113. }
  114. connection = null;
  115. }
  116.  
  117. }
  118.  
  119. <datasource jta="false" jndi-name="java:/dsFormationJSP" pool-name="dsFormationJSP" enabled="true" use-ccm="false">
  120. <connection-url>jdbc:mysql://localhost:3306/base_personne</connection-url>
  121. <driver-class>com.mysql.jdbc.Driver</driver-class>
  122. <driver>mysql-connector-java-5.1.30-bin.jarcom.mysql.jdbc.Driver_5_1</driver>
  123. <pool>
  124. <min-pool-size>50</min-pool-size>
  125. <max-pool-size>70</max-pool-size>
  126. <prefill>true</prefill>
  127. </pool>
  128. <security>
  129. <user-name>root</user-name>
  130. <password>root</password>
  131. </security>
  132. <validation>
  133. <validate-on-match>false</validate-on-match>
  134. <background-validation>false</background-validation>
  135. </validation>
  136. <timeout>
  137. <blocking-timeout-millis>50000</blocking-timeout-millis>
  138. <idle-timeout-minutes>5</idle-timeout-minutes>
  139. </timeout>
  140. <statement>
  141. <share-prepared-statements>false</share-prepared-statements>
  142. </statement>
  143. </datasource>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement