我从ruby连接到postgres数据库没有问题,但是当他们添加模式时,我感到困惑并且出错了,这是我试图运行的代码:
public class MainActivity extends AppCompatActivity {
private EditText check,check2;
private TextView textView;
private TextInputLayout checkLay,checkLay2;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initializeWidgets();
initializeListeners();
}
private void initializeWidgets(){
check=findViewById(R.id.check);
check2=findViewById(R.id.check2);
checkLay2=findViewById(R.id.checkLay2);
checkLay=findViewById(R.id.checkLay);
button=findViewById(R.id.button);
textView=findViewById(R.id.textView);
}
private void initializeListeners() {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signUp();
}
});
}
private void signUp(){
boolean isVailed=true;
int a1,a2;
String one=check.getText().toString();
String two=check2.getText().toString();
if(one.isEmpty()){
checkLay.setError("YOu need to enter something");
isVailed=false;
}
else {
if (one.length() > 0)
{
a1=Integer.parseInt(one);
if(a1> 15){
checkLay.setError("quiz marks must be less than 15");
isVailed=false;
}
else if(a1 <=15)
{
checkLay.setErrorEnabled(false);
isVailed=true;
}
}
}
if(two.isEmpty()){
checkLay2.setError("You need to enter something");
isVailed=false;
}
else{
if (two.length() > 0)
{
a2=Integer.parseInt(two);
if(a2 > 15)
{ checkLay2.setError("quiz marks must be less than 15");
isVailed=false;
}
else
if(a2 <=15)
{
checkLay2.setErrorEnabled(false);
isVailed=true;
}
}
if(isVailed)
{
int total;
a1=Integer.parseInt(one);
a2=Integer.parseInt(two);
total=a1+a2;
textView.setText(String.valueOf(total));
}
}
我收到了这个错误:
require 'pg'
@pg_conn = PGconn.connect("xxxxxxx.us-gov-west-1.rds.amazonaws.com", 5432, '', '', "BRCArchive", "yyyy", "zzzz")
count = @pg_conn.exec('SELECT COUNT(*) FROM "brcmanager.Agency"')
puts count
谢谢,
答案 0 :(得分:0)
@pg_conn.exec("set search_path=brcmanager;")
然后
count = @pg_conn.exec('SELECT COUNT(*) FROM Agency')
答案 1 :(得分:-1)
错误告诉你错了什么。表brcmanager.Agency
表不存在于该数据库中,也许您拼错了它?
您可以通过运行此SQL来查看该数据库中存在哪些表:
SELECT * FROM information_schema.tables WHERE table_schema = 'information_schema'