数据库连接测试
作者:网络转载 发布时间:[ 2016/12/30 10:11:00 ] 推荐标签:数据库
package cn.com.startdima.util;
import java.sql.Connection;
import java.sql.DriverManager;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.junit.Test;
public class Demo {
@Test
public void createTable(){
ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
//连接数据库的配置
processEngineConfiguration.setJdbcDriver("oracle.jdbc.OracleDriver");
processEngineConfiguration.setJdbcUrl("jdbc:oracle:thin:@127.0.0.1:1521:orcl");
processEngineConfiguration.setJdbcUsername("sysman");
processEngineConfiguration.setJdbcPassword("Admin123");
/**
* public static final String DB_SCHEMA_UPDATE_FALSE = "false";//不能自动创建表,需手动创建表
* public static final String DB_SCHEMA_UPDATE_CREATE_DROP = "create-drop";//先删除表再创建表
* public static final String DB_SCHEMA_UPDATE_TRUE = "true";//如果表不存在,自动创建表
*/
processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
//工作流的核心对象,processEngine对象
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
System.out.println("processEngine:"+processEngine);
}
/**
* 获取数据库连接
* @return
*/
@Test
public void getConnection(){
/** 声明Connection连接对象*/
Connection conn = null;
try{
/** 使用Class.forName()方法自动创建这个驱动程序的实例且自动调用DriverManager来注册它*/
Class.forName("oracle.jdbc.OracleDriver");
/** 通过DriverManager的getConnection()方法获取数据库连接*/
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcl",
"sysman","Admin123");
System.out.println(conn+"-------------------");
}catch(Exception ex){
ex.printStackTrace();
}
}
}
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11