To add some data in mysql using webhuddle

Developers
2009-02-19
2013-04-22
  • sanjiv kumar

    sanjiv kumar - 2009-02-19

    i have connected webhuddle with mysql its only using one table t_users for authentication user/password etc.
    now i need to store some of the data in some other table, i hv created some table my self. how to use the datasource with jdbc to use prepare-statement any other.

    have any one done or using plz suggest.

     
    • John McCaughey

      John McCaughey - 2009-02-19

      Hi,

      What are you trying to accomplish?  Using an external database for authentication doesn't mean you also have to use an external database for all the other WebHuddle data.  By default WebHuddle uses it's own database for both. 

      If can explain what your goal is that would help -- thanks!

       
    • sanjiv kumar

      sanjiv kumar - 2009-02-20

      i want to insert some of the record like path of recording zip in a table for my other application using webhuddle.

      For that whether i need to create a new DataSource in struts-config.xml
      like ...
      <data-sources>
      <data-source type="org.apache.tomcat.
      dbcp.dbcp.BasicDataSource">
          <set-property
            property="driverClassName"
            value="com.mysql.jdbc.Driver" />
          <set-property
            property="url"
            value="jdbc:mysql://localhost:3306
      /strutsdatabase?autoReconnect=true" />
          <set-property
            property="username"
            value="root" />
          <set-property
            property="password"
            value="" />
          <set-property

      and  in action file need to use the following code...

      javax.sql.DataSource dataSource;
      java.sql.Connection myConnection=null;
      String sql="insert into session values("73","xyz","abc");
             try {
              dataSource = getDataSource(request);
              myConnection = dataSource.getConnection();
              Statement
      stmt=myConnection.createStatement();
      stmt.executeUpdate(sql);

      It will work for insertion of record in table.

      thanks for reply.

       
    • sanjiv kumar

      sanjiv kumar - 2009-02-22

      hello i have created a new DBCP connection in webhuddle in stead of spring connection u provided.

      it is working fine and solved my purpose.
      thanks for reply

       

Log in to post a comment.