1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| package com.sympa.lesson01;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import javax.sql.DataSource; import java.io.FileInputStream; import java.sql.*; import java.util.Properties;
public class JdbcFirstDemo { public static void main(String[] args) throws Exception {
Properties properties = new Properties(); properties.load(new FileInputStream("src/druid.properties")); DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
Connection connection = dataSource.getConnection(); System.out.println(connection); } }
|