Web Hosting Forum | Lunarpages

Author Topic: Myql connection with client side programs  (Read 4937 times)

Offline penta7

  • Trekkie
  • **
  • Posts: 11
Myql connection with client side programs
« on: November 24, 2009, 12:06:28 AM »
Please, help me:

Did you ensure that you added the user to the database?

            Yes I do.


Next, if you did add the user and it isn't working, what exact error are you receiving.  The error is an indication of the issue occurring.

         I can run my app on  Struts just once(first time)
         When I close my browser  and I want to run my app again, I receive the connection error
The error:

"
Error al crear el ResultSet: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error: ** BEGIN NESTED EXCEPTION ** com.mysql.jdbc.exceptions.jdbc4.CommunicationsException MESSAGE: Communications link failure Last packet sent to the server was 0 ms ago. STACKTRACE: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago. at sun.reflect.GeneratedConstructorAccessor101.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance..............
.............
"


Another point would be what exact program are you using to connect? Each program is slightly different and this is useful to know if you want someone to troubleshoot the issue.

      My code is:

     protected Statement _statement;
   protected ResultSet _rs;
   private static String protocolo = "jdbc:mysql://localhost/";
   private static String driver = "com.mysql.jdbc.Driver";
   
   private static String dbname = "mydb";   
   private static String user = "myuser";
   private static String password = "mypwd";

   private boolean DEBUG = false;
   public static Connection conn = null;

   public DBService () {
      protocolo = props.getProperty("db.protocolo");
      driver = props.getProperty("db.driver");
      dbname = props.getProperty("db.dbname");
      user = props.getProperty("db.user");
      password = props.getProperty("db.password");
   
   /**
   * carga el driver para la base de datos
   * y hace la conexion  a la base de datos
   */
   public static void conectaDB () throws DBException {
      if (conn == null){
         try{
            Class.forName(driver);
            conn = DriverManager.getConnection(protocolo + dbname, user, password);            
         }
         catch (Exception ex){
            System.out.println("EN obtenoiendo el conn ERROR");
            System.out.println("connecting error");
            if (ex instanceof DBException) {
               throw new DBException("EEEerror AL CONECTARSE A LA BD EN------!"+ex.getMessage());
            }
            throw new DBException ("(2)Error al conectarse a la base de datos!!!!....");
         }
      }
   }

             ...........anhother.......

Thanks a lot in advance


Danielle

  • Guest
Re: Myql connection with client side programs
« Reply #1 on: November 24, 2009, 10:06:22 AM »
Hello penta7,

This issue is not a MySQL issue really, but a JSP and servlets one. Here is a forum thread on MySQL about a similar issue:

http://forums.mysql.com/read.php?39,139821,160175#msg-160175

You will need to review your coding for the properties setting the connection and revise them to work differently. Most people here are not JSP experts, so you should probably really go to a Struts forum and post there for help on fixing this.

Thanks.

Offline wilsonallen01

  • Newbie
  • *
  • Posts: 1
    • Buy Diamond Rings
Re: Myql connection with client side programs
« Reply #2 on: January 04, 2010, 11:13:01 PM »
Tristan is absolutely right...

This is not a issue of MySql...

Thanks

 

Share |