I am having sandbox account of Avalara(Avatax) and that is working fine on my local system and also on the staging environment. But the same sandbox credentials are not working on the UAT instance.
Error logged: avaTaxConnection java.net.SocketException: Connection reset
This is the code snippet I used :
try {
client = new AvaTaxClient("PriceBook", "1.0", "https://sandbox-
rest.avatax.com/api/v2/utilities/ping", AvaTaxEnvironment.Sandbox).withSecurity(PropertiesFileConfiguration.Avatax_AccountID,
PropertiesFileConfiguration.Avatax_LicenseKey);
PingResultModel ping = client.ping();
if (ping.getAuthenticated()) {
return client;
}
} catch (Exception e) {
LOGGER.error("ERROR in avaTaxConnection " + e);
}
When I am trying to get PingResultModel ping on the basis of the client object getting the exception: avaTaxConnection java.net.SocketException: Connection reset.
I have also checked whether the connection is created or not, but the connection is created successfully. I printed the connection object in logs.
Related
I have some remote locations that falls under same domain.When i access the remote location from windows then it opens without asking for credentials.But if i aceess the location using java code (jcifs) then it gives me this exception
jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad
password
Java code is
String path=convertToSmb(loc);
NtlmPasswordAuthentication auth=new NtlmPasswordAuthentication(path, userName, passwd);
SmbFile sFile=null;
try {
sFile=new SmbFile(path,auth);
sFile.connect();
boolean sFileExists = sFile.exists();
logger.info("checkUNCLocation [END] with :: sfileExists :: "+sFileExists);
return sFileExists;
} catch (MalformedURLException e) {
logger.error(e.getMessage(), e);
return Boolean.FALSE;
} catch (IOException e) {
logger.error(e.getMessage(), e);
return UNCNetworkConnectionWrapper.connectUNCNetwork(loc, userName, passwd);
}finally{
sFile=null;
//jcifs.Config.setProperty("jcifs.smb.client.disablePlainTextPasswords", Boolean.TRUE.toString());
}
i tried deleting all connections using net use delete but windows still did not ask for credentials
Logging also shows correct credentials.
Please guide what should be the reason.
Have you tried to set the userName and the password??
How Windows doing it is by try to connect the server using the current credentials, If you are connected with your user and you are trying to connect to other machine in the same domain, the connection will succeed , because your credentials is valid in this Domain.
Try to use your own credentials to connect to "this" server.
I'm trying to connect my Android app to my local machine database MS SQL. This is my connection string:
jdbc:jtds:sqlserver://localhost:1433/DajSve;encrypt=false;user=root;password=null;instance=FALE//SQLEXPRESS;
And I got this error:
java.sql.SQLException: Network error IOException: failed to connect to localhost/127.0.0.1 (port 1433): connect failed: ECCONREFUSED (Connection refused)
I tried a lot of things. Changed a connection string a lot of times, enabled TCP/IP and set it to port 1433, also turned off firewall but nothing helped. I'm always getting the same SQL Exception. I'm using SQL Server 2016..
try {
Class.forName(className).newInstance();
connection = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/DajSve;encrypt=false;user=root;password=null;instance=FALE//SQLEXPRESS;");
System.out.print("Uspjesno spojeni na bazu");
Statement stmt = connection.createStatement();
ResultSet reset = stmt.executeQuery("select * from Korisnik");
if (!reset.isBeforeFirst() ) {
System.out.println("nema podataka");
}else{
System.out.println("ima podataka");
}
} catch (SQLException e) {
e.printStackTrace();
System.out.print("Greska pri spajanju na bazu");
} catch (ClassNotFoundException e){
System.out.print("Greska - klasa nije pronađena");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
I know there is a lot of similar questions but none of the answers have helped
failed to connect to localhost/127.0.0.1
Your Android device isn't running a SQL Server. Give the actual server address on your network (but actually don't because you shouldn't be storing database credentials as part of your app, plus persistent JDBC connections kill battery life).
It's not a local database when your code exists on a remote device
You will actually want to create a new application that is acts as a backend API between your Android app and the database, where you can expose functions that connect to your database and parse the results there rather than doing it all in the Android app
Good day,
I have a java game that I want to play with a friend over network, I have implemented Sockets and tested the game on my pc using localhost as address, but was unable to connect to the external ip of my pal's pc, presumably due to us both being behind routers.
Here is the code of host/client:
CLIENT:
try {
socket = new Socket(inputHostIp(), 5555);
} catch (IOException e) {
e.printStackTrace();
}
SERVER:
try {
hostServer = new ServerSocket(5555);
} catch (IOException e1) {
e1.printStackTrace();
}
listenForUserConnection();
while (true) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
Socket socket = null;
try {
socket = hostServer.accept();
} catch (IOException e) {
e.printStackTrace();
continue;
}
joined(socket);
}
The exception I am getting now is
java.net.ConnectException: Connection timed out: connect
On trying to init I/O:
java.net.SocketException: Socket is not connected
java.net.Socket.getInputStream/java.net.Socket.getOutputStream
I have set up port forwarding with the chosen port number (5555) linked to the internal ip on both our machines.
What are my options for getting this to work?
ADDENDUM:
We have also tried using Hamachi to create a virtual LAN, but there seems to be an issue with that - we can’t ping one another even through that, it diagnoses with an issue -
Tunnel:
VPN domain's tap device is down
Local results:
Adapter configuration:
Cannot get adapter config
Traffic test: Cannot complete test
Peer results: [160-056-951]
Adapter configuration: OK
Traffic test: Inbound traffic blocked, check firewall settings
I have tried shutting down firewalls, hamachi issues changed to just ‘cannot get adapter config’, but otherwise no results.
On my pc, however, I got a version of windows that doesn’t seem to display Firewall setting properly, if you think it’s likely an issue, can you tip me on how to test my firewall?
I`m trying to test connection timeout property for jaxws client which is deployed on IBM Websphere Application Server 8.5. I set timeout properties the following way:
((BindingProvider) port).getRequestContext().
put(com.ibm.wsspi.webservices.Constants.RESPONSE_TIMEOUT_PROPERTY, "30");
((BindingProvider) port).getRequestContext().
put(com.ibm.wsspi.webservices.Constants.CONNECTION_TIMEOUT_PROPERTY, "15";
RESPONSE_TIMEOUT_PROPERTY works fine.
But I have no idea how to test CONNECTION_TIMEOUT_PROPERTY. If webservice is not available during creating an instance of Service I get the following exception:
javax.xml.ws.WebServiceException: The following WSDL exception occurred:
WSDLException: faultCode=WSDL4JWrapper : : javax.wsdl.WSDLException:
WSDLException: faultCode=WSDL4JWrapper : :
java.net.ConnectException: Connection refused: connect
If webservice is not available during creating port(invoking getPort(...) method) I get the following exception:
javax.xml.ws.WebServiceException:
java.net.ConnectException: HTTP ( 404 ) Not Found address :
http://myhost:myport/WsServer/helloService
Exceptions are thrown immediately. I suppose I do something wrong. Any pointers would be helpful.
There needs to be a socket open on the server to accept the connection.
Try something like the following
public static void main(String[] args) {
int port = Integer.parseInt(args[0]);
try (ServerSocket serviceStub = new ServerSocket(port)) {
while (true) {
serviceStub.accept();
System.out.println("Something connected");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
Run this on the server (with whatever port you need). It will accept a connection but will never do anything which ought to simulate your timeout.
Generally, anything that listens on a port and does nothing should fit the bill.
I have downloaded JDK 6 and also I have sqljdb4.jar and I have database.properties file that content the following data
database.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
database.url=jdbc:sqlserver://.;databaseName=UserInfo;integratedSecurity=true;
database.username=sa
database.password=admin
B.N : I'm installing the server on my machine and the server name = . , also I'm using Windows Authontication
My problem now is when I try to create connection I have the following error
com.microsoft.sqlserver.jdbc.SQLServerException:
The TCP/IP connection to the host
localhost, port 1433 has failed.
Error: Connection refused: connect.
Please verify the connection
properties and check that a SQL Server
instance is running on the host and
accepting TCP/IP connections at the
port, and that no firewall is blocking
TCP connections to the port. at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
I don't know what is the exact problem here
If any one can help I will be appreciated
Thanks in Advance
That's caused by many probabilities like
1- IP is worong
2- Port is wrong
3- There is firewall prevent machine to go out and connect to another IP
4- SQL server down .
try to use
public class JdbcSQLServerDriverUrlExample
{
public static void main(String[] args)
{
Connection connection = null;
try
{
// the sql server driver string
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// the sql server url
String url = "jdbc:microsoft:sqlserver://HOST:1433;DatabaseName=DATABASE";
// get the sql server database connection
connection = DriverManager.getConnection(url,"THE_USER", "THE_PASSWORD");
// now do whatever you want to do with the connection
// ...
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
System.exit(1);
}
catch (SQLException e)
{
e.printStackTrace();
System.exit(2);
}
}
}
What i need to explain is there is very good technology called " Persistence " is better than JDBC and is more than brilliant and easy to use .
The problem is that your SQL server is either
not installed,
not running or
not accepting TCP/IP connections.
Particularly the last one is nasty, as I remember that some versions of SQL Server have not configured the TCP/IP connector to run by default.
Well first and foremost we need to see your code. Second looking at the error message the database is A)not running
B) on a different port
or C) the code is incorrect.