1
我試圖把我的項目放在travis上,但是我無法與我的數據庫進行簡單的連接。我正在使用postgres。用travis在javaproject上設置postgres db
這裏是我的配置文件: 特拉維斯鏈接:https://travis-ci.org/victorsilent/SB01/jobs/104453066
.travis.yml
# target programming lamguage
language: java
# JDK versios support
jdk:
- oraclejdk7
- oraclejdk8
addons:
postgresql: "9.4"
sudo: required
services:
- postgresql
# run tests, findbugs, pmd and friends using Ant, Maven or Gradle
script: ant test
before_script:
- psql -c "create database teste2;" -U postgres
- psql -c "create schema trabalho;" -U postgres
- psql -c "set search_path to 'trabalho'" -U postgres
我的測試簡單的測試
@Test(expected=Exception.class)
public void testeStat() throws Exception{
try{
Class.forName("org.postgresql.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/teste2?currentSchema=trabalho","postgres","admin");
Statement stmt = null;
stmt = connection.createStatement();
String query = "CREATE TABLE meubanco " +
"(id INTEGER not NULL, " +
" age INTEGER, " +
" PRIMARY KEY (id))";
stmt.executeUpdate(query);
}catch(Exception e) {
throw new Exception(e);
}
}
但我的連接得到rekt永遠! 這些代碼有什麼問題?