[opencms-dev] best practice mySql configuration

Flavio flavio.suigo at dinamys.it
Thu Dec 4 12:16:01 CET 2003


Here an example of JSP:

<html>
<head>
<%@ page
     import = "java.io.*"
     import = "java.lang.*"
     import = "java.sql.*"
     import = "java.util.*"
     import = "com.TestDB"
     import = "com.opencms.flex.jsp.*"
%>
<title>
JSP Example
</title>
</head>
<body>
<h1>JSP Example</h1>
<%
     String    place;
     Connection dbconn;
     ResultSet results;
     PreparedStatement sql;
     try
     {
          Class.forName("org.gjt.mm.mysql.Driver");
          try
          {
               String host = null;
               String user = null;
               boolean   doneheading = false;
               dbconn = DriverManager.getConnection
("jdbc:mysql://localhost/opencms","","");
               place = request.getParameter("place");
               sql = dbconn.prepareStatement("select * from cms_users");
               results = sql.executeQuery();
               while(results.next())
               {
                    if(! doneheading)
                    {
                         out.println("<table border=2>");
                         doneheading = true;
                    }
                                host = results.getString(1);
                                user = results.getString(2);
                    out.println("<tr><td>" + host + "</td>");
                    out.println("<td>" + user + "</td></tr>");
               }
               if(doneheading)
               {
                    out.println("</table>");
               }
               else
               {
                    out.println("No matches for " + place);
               }

                        out.println("<BR>Estrazione dato...");
               sql = dbconn.prepareStatement("select file_content from
cms_backup_files where file_id = 1173");
               results = sql.executeQuery();
                        out.println("<BR>Dato letto");
               if(results.next())
               {
                                ResultSetMetaData rsmd =
results.getMetaData();
                                int tipo = rsmd.getColumnType(1);
                                out.println("<BR>Tipo = " + tipo + "<BR>");

                                out.println("<BR>Lettura file...");
                                Blob fileBlob = results.getBlob(1);

                                InputStream ip = fileBlob.getBinaryStream
();
                                try
                                {
                                  OutputStream op = new FileOutputStream
("c:/1173.doc");
                                  int bytelen = 0;

                                  out.println("<BR>Salvataggio file...");
                                  try
                                  {
                                    while(true)
                                    {
                                      int i = ip.read();
                                      if(i < 0)
                                        break;
                                      op.write(i);
                                      bytelen++;
                                    }

                                    ip.close();
                                    op.close();
                                  }
                                  catch(Exception ex1)
                                  {
                                    out.println(ex1);
                                  }
                                  out.println("<BR>File salvato!<BR>");
                                }
                                catch(Exception ex)
                                {
                                  out.println(ex);
                                }
               }
          }
          catch (SQLException s)
          {
               out.println("SQL Error<br>" + s.getMessage());
          }
     }
     catch (ClassNotFoundException err)
     {
          out.println("Class loading error");
        }
%>
</body>
</html>

Bye bye!!!
Flavio Suigo




                                                                                                                        
                    "Sarah Ceriani"                                                                                     
                    <sceriani at sapient.c       To:     <opencms-dev at opencms.org>                                         
                    om>                       cc:                                                                       
                    Sent by:                  Subject:     [opencms-dev] best practice mySql configuration              
                    opencms-dev-admin at o                                                                                 
                    pencms.org                                                                                          
                                                                                                                        
                                                                                                                        
                    04/12/2003 11.41                                                                                    
                    Please respond to                                                                                   
                    opencms-dev                                                                                         
                                                                                                                        
                                                                                                                        




Hi all,
does someone has some best practices for mySql configuration with OpenCMS?


Thanks in advance.
sarah

















More information about the opencms-dev mailing list