List of usage examples for org.apache.commons.dbcp BasicDataSource setUrl
public synchronized void setUrl(String url)
Sets the #url .
Note: this method currently has no effect once the pool has been initialized.
From source file:mx.com.pixup.portal.demo.DemoDisqueraUpdate.java
public static void main(String[] args) { System.out.println("BIENVENIDO A PIXUP"); System.out.println("Mantenimiento catlogo disquera"); System.out.println("Actualizacin de Disquera"); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); Connection connection = null; Statement statement = null;/*from w w w. j av a 2 s .c o m*/ ResultSet resultSet = null; try { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("root"); dataSource.setPassword("admin"); dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/pixup"); connection = dataSource.getConnection(); statement = connection.createStatement(); String sql = "select id, nombre from disquera order by nombre"; resultSet = statement.executeQuery(sql); System.out.println("Id Disquera: \t Nombre Disquera"); while (resultSet.next()) { System.out.println(resultSet.getInt("id") + " \t " + resultSet.getString("nombre")); } System.out.println("Proporcione el id de la disquera a actualizar: "); String idDisquera = br.readLine(); System.out.println("Proporcione el nuevo nombre de la disquera: "); String nombreDisquera = br.readLine(); sql = "update disquera set nombre = '" + nombreDisquera + "' where id = " + idDisquera; statement.execute(sql); System.out.println("Disqueras Actualizadas:"); sql = "select id, nombre from disquera order by nombre desc"; resultSet = statement.executeQuery(sql); System.out.println("Id Disquera: \t Nombre Disquera"); while (resultSet.next()) { System.out.println(resultSet.getInt("id") + " \t " + resultSet.getString("nombre")); } } catch (Exception e) { System.out.println("Error en el sistema, intente ms tarde!!"); } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { } } if (statement != null) { try { statement.close(); } catch (Exception e) { } } if (connection != null) { try { connection.close(); } catch (Exception e) { } } } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.output.OutputWriter.java
public static void main(String[] args) { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUsername("jmarkets"); ds.setPassword("banana"); String dbHost = "david.ssel.caltech.edu"; String dbPort = "3306"; String dbName = "jmarkets"; ds.setUrl("jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName); //ds.setUrl("jdbc:mysql://localhost:3306/jmarkets"); ds.setMaxActive(10);/*w w w . jav a 2 s . c o m*/ OutputWriter writer = new OutputWriter(); writer.outputSession(145, "c://output.csv"); }
From source file:DynaBeansExampleV2.java
private static Connection getConnection() throws Exception { BasicDataSource bds = new BasicDataSource(); bds.setDriverClassName("com.mysql.jdbc.Driver"); bds.setUrl("jdbc:mysql://localhost/commons"); bds.setUsername("root"); bds.setPassword(""); //bds.setInitialSize(5); return bds.getConnection(); }
From source file:DynaBeansExampleV3.java
private static Connection getConnection() throws Exception { BasicDataSource bds = new BasicDataSource(); bds.setDriverClassName("com.mysql.jdbc.Driver"); bds.setUrl("jdbc:mysql://localhost/commons"); bds.setUsername("root"); bds.setPassword(""); // bds.setInitialSize(5); return bds.getConnection(); }
From source file:com.github.ipan97.belajar.hashMD5.application.App.java
public static DataSource getDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/belajar"); //set user database dataSource.setUsername("root"); //set password dataSource.setPassword("admin"); return dataSource; }
From source file:aplikasi.config.KoneksiDB.java
public static DataSource getDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setUsername("root"); ds.setPassword("admin"); ds.setUrl("jdbc:mysql://localhost:3306/sipmi"); ds.setDriverClassName("org.mariadb.jdbc.Driver"); return ds;// w w w . ja va 2s . co m }
From source file:com.devwebsphere.wxs.jdbcloader.TestJDBCLoader.java
@BeforeClass static void setup() throws Exception { Class.forName(EmbeddedDriver.class.getName()); BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(EmbeddedDriver.class.getName()); ds.setUrl("jdbc:derby:derbyDB;create=true"); Connection connTest = ds.getConnection(); Assert.assertNotNull(connTest);/*from w w w . jav a2 s .c o m*/ connTest.close(); }
From source file:com.dangdang.ddframe.rdb.transaction.soft.AsyncJobMain.java
private static DataSource createDataSource(final String dataSourceName) { BasicDataSource result = new BasicDataSource(); result.setDriverClassName("com.mysql.jdbc.Driver"); result.setUrl(String.format("jdbc:mysql://localhost:3306/%s", dataSourceName)); result.setUsername("root"); result.setPassword(""); return result; }
From source file:com.dangdang.ddframe.rdb.transaction.soft.AsyncJobMain.java
private static DataSource createTransactionLogDataSource() { BasicDataSource result = new BasicDataSource(); result.setDriverClassName("com.mysql.jdbc.Driver"); result.setUrl("jdbc:mysql://localhost:3306/trans_log"); result.setUsername("root"); result.setPassword(""); return result; }
From source file:cz.muni.fi.pv168.dressroommanager.TryDB.java
private static DataSource prepareDataSource() throws SQLException { BasicDataSource ds = new BasicDataSource(); //we will use in memory database ds.setUrl("jdbc:derby:memory:closetmgr-test;create=true"); return ds;/*from ww w.j a v a2 s . c om*/ }