我试图将我的项目放在travis上,但我无法与我的数据库建立简单的连接。我正在使用postgres。
这是我的配置文件: 特拉维斯链接: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! 这些代码有什么问题?
答案 0 :(得分:0)
要解决此问题,我将架构更改为公开,添加
- pg_restore -U postgres -d bdvendas BancoVendas.backup
在我的.travis.yml上,并将我的.backup数据库放在github存储库上。