Package javax.sql

Examples of javax.sql.DataSource


    // Note: your JDBC driver must be loaded [via Class.forName( ... ) or -Djdbc.properties]
    // prior to acquiring your DataSource!

    // Acquire the DataSource... this is the only c3p0 specific code here
    DataSource ds = DataSources.unpooledDataSource("jdbc:postgresql://localhost/test",
                     "swaldman",
                     "test");

    // get hold of a Connection an do stuff, in the usual way
    Connection con  = null;
    Statement  stmt = null;
    ResultSet  rs   = null;
    try
        {
      con = ds.getConnection();
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT * FROM foo");
      while (rs.next())
          System.out.println( rs.getString(1) );
        }
View Full Code Here


                if ( "connectionPoolDataSource".equals( propName ) )
                {
                    if (val instanceof WrapperConnectionPoolDataSource)
                    {
                        DataSource nested = (DataSource) ((WrapperConnectionPoolDataSource)val).getNestedDataSource();
                        if (! (nested instanceof DriverManagerDataSource) )
                            throw new PropertyVetoException("ComboPooledDataSource requires that its unpooled DataSource " +
                                            " be set at all times, and that it be a" +
                                            " com.mchange.v2.c3p0.DriverManagerDataSource. Bad: " + nested, evt);
                    }
View Full Code Here

    ManagedConnectionImpl mConn = ((UserConnection) conn).getMConn();
   
    String url = mConn.getURL();
    String driver = mConn.getDriverClass().getCanonicalName();
   
    DataSource ds = findDatabase(driver, url);
   
    ((DBPool) ds).markForPoolRemoval(mConn);
  }
View Full Code Here


      if (serverId.isEmpty())
        serverId = "default";
     
      DataSource dataSource = createDataSource(dataDirectory, serverId);
      String tableName = "mnode";

      _mnodeStore = new MnodeStore(dataSource, tableName, serverId);
      _mnodeStore.init();
     
View Full Code Here

  {
    if (pageContext.getAttribute("caucho.jstl.sql.conn") != null)
      throw new JspTagException(L.l("nested sql:transaction are forbidden"));

    try {
      DataSource ds;

      ds = SqlQueryTag.getDataSource(pageContext, _dataSource);

      int isolationCode = -1;
      if (_isolation == null) {
      }
      else if (_isolation.equals("read_committed"))
        isolationCode = Connection.TRANSACTION_READ_COMMITTED;
      else if (_isolation.equals("read_uncommitted"))
        isolationCode = Connection.TRANSACTION_READ_UNCOMMITTED;
      else if (_isolation.equals("repeatable_read"))
        isolationCode = Connection.TRANSACTION_REPEATABLE_READ;
      else if (_isolation.equals("serializable"))
        isolationCode = Connection.TRANSACTION_SERIALIZABLE;
      else
        throw new JspTagException(L.l("unknown sql:transaction isolation ~{0}'", _isolation));

      _conn = ds.getConnection();

      _oldIsolation = _conn.getTransactionIsolation();

      _conn.setAutoCommit(false);
     
View Full Code Here

      if (value instanceof DataSource)
        return (DataSource) value;
    } catch (NamingException e) {
    }

    DataSource dataSource = getDataSource(key);

    if (dataSource != null)
      return dataSource;
   
    throw new JspException(L.l("'{0}' is an invalid DataSource.", ds));
View Full Code Here

    String var = _var;

    if (var == null)
      var = Config.SQL_DATA_SOURCE;

    DataSource dataSource = null;

    if (_dataSource != null)
      dataSource = SqlQueryTag.getDataSource(pageContext, _dataSource);
    else
      dataSource = openDataSource(_driver, _url, _user, _password);
View Full Code Here

   */
  public void createDatabaseTable(AmberPersistenceUnit amberPersistenceUnit)
    throws ConfigException
  {
    try {
      DataSource ds = amberPersistenceUnit.getDataSource();
      Connection conn = ds.getConnection();
      try {
        Statement stmt = conn.createStatement();

        try {
          // If the table exists, return
View Full Code Here

   */
  public void validateDatabaseTable(AmberPersistenceUnit amberPersistenceUnit)
    throws ConfigException
  {
    try {
      DataSource ds = amberPersistenceUnit.getDataSource();
      Connection conn = ds.getConnection();
      try {
        Statement stmt = conn.createStatement();

        try {
          // If the table exists, return
View Full Code Here

  {
    if (_isInit)
      return;
    _isInit = true;

    DataSource ds = amberPersistenceUnit.getDataSource();
    Connection conn = ds.getConnection();
    try {
      JdbcMetaData metaData = amberPersistenceUnit.getMetaData();

      _selectSQL = metaData.selectSequenceSQL(_name);
View Full Code Here

TOP

Related Classes of javax.sql.DataSource

Copyright © 2018 www.massapicom. 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.