Package dataaccess

Source Code of dataaccess.DBAccess

package dataaccess;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

public class DBAccess {
 
  public static MysqlDataSource ReturnDataSource()
  {
    MysqlDataSource dataSource = new MysqlDataSource();
    dataSource.setServerName("localhost");
    dataSource.setUser("sourceforge");
      dataSource.setPassword("dont4get");
      dataSource.setDatabaseName("sourceforge");
      dataSource.setPort(3306);
     
      return dataSource;
  }
 
  public Boolean save(String i_query)
  {
      MysqlDataSource l_ds = DBAccess.ReturnDataSource();
      Connection l_con = null;
      Statement l_stat = null;
     
      int l_anz = 0;
      try

      {
        l_con = l_ds.getConnection();
      l_stat = l_con.createStatement()

       
      l_stat.execute(i_query);
   
      }
      catch (Exception e)
      {
        return false;
      }
      try
      {
        l_stat.close();
        l_con.close();
      }
      catch(Exception e)
      {
       
      }
      return true;
  }

}
TOP

Related Classes of dataaccess.DBAccess

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.