I'm trying to connect to a URL in an AsynTask but am having trouble.
Document doc = Jsoup.connect("https://www.gasbuddy.com/home?search=33444&fuel=1").get();
gives me an error in my log saying:
Error Connecting: failed to connect to www.gasbuddy.com/104.17.148.191 (port 443) after 30000ms
After doing some research, I believe I need to connect to the baseURL. However, I'm not sure how to do this. I've tried:
URL absoluteUrl = new URL(new URL("https://www.gasbuddy.com/home?search=33444&fuel=1"), "script.js");
Document doc = Jsoup.connect(String.valueOf(absoluteUrl)).get();
But I get the same error in my my logs.
Edit: I get the same error on any website I try connecting too ("https://www.yahoo.com/", "https://www.google.com/", etc) I'm on a a public Starbucks Wifi at the moment, not sure if that matters.
Related
My Code below:
System.out.println("Linkedin URL="+"https://"+linkedinUrl);
Document aResponseDocument= null;
//Connection.Response aResponse = Jsoup.connect("https://www.linkedin.com/in/noah-bennett-453a4833").cookies(response.cookies()).method(Connection.Method.GET).execute();
Connection connection = Jsoup.connect("https://"+linkedinUrl)
//.referrer("http://localhost:8080")
//.headers(headerMap)
.cookies(response.cookies())
.method(Connection.Method.GET);
this work using localhost but when run on production server it returned HTTP response code: 999 for URL.
I want to ask you a question about this exception. I need more information but i dont find anything. Actually this test i am receiving this exception:
com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection timed out: connect
The url also exists and retrieve me data if i put that url in a browser. The exception raises in the line of the ClientResponse. Please give more info. Actually im using a proxy to establish connection with the server , but my data are OK, in my project.properties. Any idea why happens this??. Im communicating with a remote server , no in localhost.
Client client = Client.create();
WebResource webResource = client
.resource("http://someurl");
String input= "{'test'}";
ClientResponse response = webResource.type("application/json")
.post(ClientResponse.class, input);
I am trying to call URL from java but am getting error as java.net.UnknownHostException:
Java Code:
URL url = new URL("http://www.gettingagile.com/feed/rss2/");
HttpURLConnection request = (HttpURLConnection) url.openConnection();
String code = String.valueOf(request.getResponseCode());
System.out.println("Error code "+code);
An UnknownHostException generally means that java couldn't resolve the host, in this case www.gettingagile.com.
Maybe your firewall is blocking access for java, maybe your computer is not connected to the internet or there might be a problem with your DNS server.
Can you surf to www.gettingagile.com in your browser? And can you ping the address from a shell or commandline?
I am getting a 404 error when using Jsoup. The call is Document doc = Jsoup.parse(url, 30000) and the URL string is http://www.myland.co.il/%D7%9E%D7%97%D7%A9%D7%91-%D7%94%D7%A9%D7%A7%D7%99%D7%94
and the URL displays fine in Chrome. The error I am getting is java.io.IOException: 404 error loading URL http://www.myland.co.il/vmchk/××ש×-×שק××
Any ideas?
Don't use parse()-method for websites, use connect() instead. So you can set more connection settings.
final String url = "http://www.myland.co.il/%D7%9E%D7%97%D7%A9%D7%91-%D7%94%D7%A9%D7%A7%D7%99%D7%94";
Document doc = Jsoup.connect(url).get();
However the problem is the url-encoding:
Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=404, URL=http://www.myland.co.il/vmchk/××ש×-×שק××
Even decoding the url back to utf-8 doesn't solve this.
Do you have an "alternative" url?
try decodeURL()
String url = "http://www.myland.co.il/%D7%9E%D7%97%D7%A9%D7%91-%D7%94%D7%A9%D7%A7%D7%99%D7%94";
Document doc = Jsoup.connect(url.decodeURL()).get();
What is the actual difference between the following 2 declarations of JDBC URL?
1. jdbc:oracle:thin:#//hostname:1521/servicename
2. jdbc:oracle:thin:#hostname:1521:sidid
Reason for the question:
URL1 works for only for some specific oracle database whereas URL2 seems to work for all types of data. Can the URL2 format be used for the servicename also?
Issue:
I got the following error when I used URL1 against certain database.
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
The Connection descriptor used by the client was:
//hostname:1521/sidid
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
Solution:
Used URL2 and it fixed the above TNS error.
Edited:
Changed the format of the URL to servicename from sid.
Why it is throwing an error when just the format its expecting for a sid is different from service?