Re: user can't access own database after creation

From: Steven Schlansker <stevenschlansker(at)gmail(dot)com>
To: Nuno Zimas <nzimas(at)gmail(dot)com>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, John R Pierce <pierce(at)hogranch(dot)com>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: user can't access own database after creation
Date: 2015-12-02 20:53:43
Message-ID: 5C503E8A-42CD-4E6D-BB71-8403DEB50D49@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Change

public static void main(String []args)

to

public static void main(String []args) throws Exception

On Dec 2, 2015, at 12:52 PM, Nuno Zimas <nzimas(at)gmail(dot)com> wrote:

> Thanks, Steve. How silly of me :(
> Still falling to compile, though.
>
> root(at)aida2next /u/2next# javac TestUrl.java
> TestUrl.java:10: error: unreported exception SQLException; must be caught or declared to be thrown
> Connection con = java.sql.DriverManager.getConnection("jdbc:postgresql://10.10.10.100","postgres","smartdoc");
> ^
> TestUrl.java:11: error: unreported exception SQLException; must be caught or declared to be thrown
> con.createStatement().execute("select 1");
> ^
> TestUrl.java:11: error: unreported exception SQLException; must be caught or declared to be thrown
> con.createStatement().execute("select 1");
> ^
> 3 errors
>
>
>
>> On 2 Dec 2015, at 20:50, Steven Schlansker <stevenschlansker(at)gmail(dot)com> wrote:
>>
>> That's easily fixed by adding the missing ';' just as the error indicates :)
>>
>> On Dec 2, 2015, at 12:48 PM, Nuno Zimas <nzimas(at)gmail(dot)com> wrote:
>>
>>>
>>> Hi Dave,
>>>
>>> I’m getting an error.
>>>
>>> root(at)aida2next /u/2next# javac TestUrl.java
>>> TestUrl.java:1: error: ';' expected
>>> import java.sql.Connection
>>> ^
>>> 1 error
>>>
>>>
>>>
>>>> On 2 Dec 2015, at 20:39, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>>>>
>>>> this isn't compiled, but it has no dependencies to compile and only one to run
>>>>
>>>> import java.sql.Connection
>>>>
>>>> /**
>>>> * Created by davec on 2014-03-28.
>>>> */
>>>> class TestUrl
>>>> {
>>>> public static void main(String []args)
>>>> {
>>>> Connection con = java.sql.DriverManager.getConnection("jdbc:postgresql://yourhost","youruser","password");
>>>> con.createStatement().execute("select 1");
>>>> }
>>>> }
>>>> save it in a file called TestUrl.java
>>>> compile it with javac TestUrl.java
>>>> run it with java -cp postgresql.jar:./ TestUrl
>>>>
>>>> change the names above to suit
>>>>
>>>> Dave Cramer
>>>>
>>>> davec(at)postgresintl(dot)com
>>>> www.postgresintl.com
>>>>
>>>> On 2 December 2015 at 15:35, Nuno Zimas <nzimas(at)gmail(dot)com> wrote:
>>>>
>>>>> On 2 Dec 2015, at 20:18, Dave Cramer <pg(at)fastcrypt(dot)com> wrote:
>>>>>
>>>>> Can you try a very simple JDBC program to see if you can connect ?
>>>>>
>>>>> Dave Cramer
>>>>
>>>> Could you please suggest one already compiled?
>>>> I’m not a java programmer and it’s been hell on rather to compile even the simplest java source file due to dependency issues.
>>>>
>>>>>
>>>>> davec(at)postgresintl(dot)com
>>>>> www.postgresintl.com
>>>>>
>>>>> On 2 December 2015 at 14:57, John R Pierce <pierce(at)hogranch(dot)com> wrote:
>>>>> On 12/2/2015 11:55 AM, Nuno Zimas wrote:
>>>>> psql always connects successfully no matter what.
>>>>> As for JDBC, we get the same results with or without ssl=true explicitly appended to the URL.
>>>>> What truly baffles me is that ye exact same java application works with no hiccups against a quasi-vanilla pgsql backend i’ve installed on windows 10.
>>>>> So far, the only visible difference I found is in the values for LC_COLLATE and LC_TYPE, which is V on the remote pgsql instances and English_United States.1252 on the local pgsql instance.
>>>>> Not sure how tis would affect accessing the DBs, though.
>>>>>
>>>>> can you connect using psql on the windows system to the ubuntu hosted database?
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> john r pierce, recycling bits in santa cruz
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgsql-jdbc
>>>>>
>>>>
>>>>
>>>
>>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nuno Zimas 2015-12-02 21:00:36 Re: user can't access own database after creation
Previous Message Nuno Zimas 2015-12-02 20:52:52 Re: user can't access own database after creation