Codota Logo
SimpleDataSourceFactory.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.jfaster.mango.datasource.SimpleDataSourceFactory
constructor

Best Java code snippets using org.jfaster.mango.datasource.SimpleDataSourceFactory.<init> (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: jfaster/mango

public void setDataSource(DataSource dataSource) {
 if (dataSource == null) {
  throw new NullPointerException("dataSource can't be null");
 }
 setDataSourceFactory(new SimpleDataSourceFactory(dataSource));
}
origin: fang-yan-peng/cronner

@Override
public Mango createMango() {
  try {
    Mango mango = Mango.newInstance(new SimpleDataSourceFactory(CronnerConstant.DB,buildDataSource()));
    this.mango = mango;
    return mango;
  } catch (Exception e) {
    logger.error("Init datasource error",e);
    throw e;
  }
}
origin: jfaster/mango-example

public static void main(String[] args) {
  String driverClassName = "com.mysql.jdbc.Driver";
  String username = "root"; // 这里请使用您自己的用户名
  String password = "root"; // 这里请使用您自己的密码
  int dbNum = 3;
  List<DataSourceFactory> dsfs = new ArrayList<DataSourceFactory>();
  for (int i = 0; i < dbNum; i++) {
    String name = "dsf" + i;
    String url = "jdbc:mysql://localhost:3306/db" + i;
    DataSource ds = new DriverManagerDataSource(driverClassName, url, username, password);
    DataSourceFactory dsf = new SimpleDataSourceFactory(name, ds);
    dsfs.add(dsf);
  }
  Mango mango = Mango.newInstance(dsfs);
  DatabaseShardingOrderDao orderDao = mango.create(DatabaseShardingOrderDao.class);
  List<Integer> uids = Lists.newArrayList(1, 2, 3, 4, 5);
  for (Integer uid : uids) {
    String id = RandomUtils.randomStringId(10); // 随机生成10位字符串ID
    Order order = new Order();
    order.setId(id);
    order.setUid(uid);
    order.setPrice(100);
    order.setStatus(1);
    orderDao.addOrder(order);
    System.out.println(orderDao.getOrdersByUid(uid));
  }
}
origin: jfaster/mango-example

public static void main(String[] args) {
  String driverClassName = "com.mysql.jdbc.Driver";
  String username = "root"; // 这里请使用您自己的用户名
  String password = "root"; // 这里请使用您自己的密码
  int dbNum = 3;
  List<DataSourceFactory> dsfs = new ArrayList<DataSourceFactory>();
  for (int i = 0; i < dbNum; i++) {
    String name = "dsf" + i;
    String url = "jdbc:mysql://localhost:3306/db" + i;
    DataSource ds = new DriverManagerDataSource(driverClassName, url, username, password);
    DataSourceFactory dsf = new SimpleDataSourceFactory(name, ds);
    dsfs.add(dsf);
  }
  Mango mango = Mango.newInstance(dsfs);
  SmartShardingOrderDao orderDao = mango.create(SmartShardingOrderDao.class);
  List<Integer> uids = Lists.newArrayList(1, 2, 3, 30001, 30002, 30003);
  for (Integer uid : uids) {
    String id = RandomUtils.randomStringId(10); // 随机生成10位字符串ID
    Order order = new Order();
    order.setId(id);
    order.setUid(uid);
    order.setPrice(100);
    order.setStatus(1);
    orderDao.addOrder(order);
    System.out.println(orderDao.getOrdersByUid(uid));
  }
}
origin: jfaster/mango-example

public static void main(String[] args) {
  String driverClassName = "com.mysql.jdbc.Driver";
  String username = "root"; // 这里请使用您自己的用户名
  String password = "root"; // 这里请使用您自己的密码
  int dbNum = 3;
  List<DataSourceFactory> dsfs = new ArrayList<DataSourceFactory>();
  for (int i = 0; i < dbNum; i++) {
    String name = "dsf" + i;
    String url = "jdbc:mysql://localhost:3306/db" + i;
    DataSource ds = new DriverManagerDataSource(driverClassName, url, username, password);
    DataSourceFactory dsf = new SimpleDataSourceFactory(name, ds);
    dsfs.add(dsf);
  }
  Mango mango = Mango.newInstance(dsfs);
  ShardingOrderDao orderDao = mango.create(ShardingOrderDao.class);
  List<Integer> uids = Lists.newArrayList(1, 2, 3, 30001, 30002, 30003);
  for (Integer uid : uids) {
    String id = RandomUtils.randomStringId(10); // 随机生成10位字符串ID
    Order order = new Order();
    order.setId(id);
    order.setUid(uid);
    order.setPrice(100);
    order.setStatus(1);
    orderDao.addOrder(order);
    System.out.println(orderDao.getOrdersByUid(uid));
  }
}
origin: jfaster/mango-example

String url = "jdbc:mysql://localhost:3306/db" + i;
DataSource ds = new DriverManagerDataSource(driverClassName, url, username, password);
DataSourceFactory dsf = new SimpleDataSourceFactory(name, ds);
dsfs.add(dsf);
origin: jfaster/mango-example

public static void main(String[] args) {
  String driverClassName = "com.mysql.jdbc.Driver";
  String url = "jdbc:mysql://localhost:3306/mango_example";
  String username = "root"; // 这里请使用您自己的用户名
  String password = "root"; // 这里请使用您自己的密码
  DataSource datasource = new DriverManagerDataSource(driverClassName, url, username, password);
  DataSourceFactory dsf = new SimpleDataSourceFactory(datasource);
  Mango mango = Mango.newInstance(dsf);
  //Mango mango = Mango.newInstance(datasource);
  ArticleDao dao = mango.create(ArticleDao.class);
  Article article = new Article();
  article.setUid(9527);
  article.setTitle("article_title");
  article.setContent("article_content");
  int id = dao.addArticle(article);
  System.out.println(dao.getArticle(id));
}
origin: jfaster/mango-example

String url2 = "jdbc:mysql://localhost:3306/mango_example_db2";
DataSource datasource = new DriverManagerDataSource(driverClassName, url2, username, password);
DataSourceFactory dsf2 = new SimpleDataSourceFactory(name2, datasource);
org.jfaster.mango.datasourceSimpleDataSourceFactory<init>

Popular methods of SimpleDataSourceFactory

    Popular in Java

    • Making http post requests using okhttp
    • orElseThrow (Optional)
      Return the contained value, if present, otherwise throw an exception to be created by the provided s
    • setContentView (Activity)
    • getApplicationContext (Context)
    • Time (java.sql)
      Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
    • Arrays (java.util)
      This class contains various methods for manipulating arrays (such as sorting and searching). This cl
    • PriorityQueue (java.util)
      An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
    • Set (java.util)
      A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
    • JCheckBox (javax.swing)
    • JFrame (javax.swing)
    Codota Logo
    • Products

      Search for Java codeSearch for JavaScript codeEnterprise
    • IDE Plugins

      IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Codota for your IDE now