Java Can';t连接到SOCKS代理:连接被拒绝:连接
我得到以下错误。检查许多解决方案,但没有得到结果 Not Connected to the database - networkcoding com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure ERROR: java.lang.NullPointerException The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 错误在代码的以下部分中:Java Can';t连接到SOCKS代理:连接被拒绝:连接,java,mysql,swing,netbeans,Java,Mysql,Swing,Netbeans,我得到以下错误。检查许多解决方案,但没有得到结果 Not Connected to the database - networkcoding com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure ERROR: java.lang.NullPointerException The last packet sent successfully to the server was 0
package privacysensor;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import javax.swing.JOptionPane;
public class Sensors extends javax.swing.JFrame {
/**
* Creates new form Sensors
*/
String s1 = "", s2 = "", s3 = "", s4 = "", s5 = "", s6 = "", s7 = "", s8 = "", s9 = "";
DBConnect c = new DBConnect();
DateFormat df = new SimpleDateFormat("hh:mm a");
Calendar cal1 = Calendar.getInstance();
org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(
privacysensor.PrivacySensorApp.class).getContext().getResourceMap(Sensors.class);
Class1 x = new Class1();
int id, id1;
public Sensors() {
initComponents();
try {
id = x.idgeneration();
id1 = x.Tidgeneration();
Connection c1 = c.getConnection();
Connection c2 = c.getConnection();
PreparedStatement pst = c1.prepareStatement("update sensors set status='Offline' where id=" + id);
int s = pst.executeUpdate();
if (s == 0) {
System.out.println("Not updated");
} else {
System.out.println("Updated");
}
PreparedStatement pst1 = c2.prepareStatement("update timing set status='Offline' where id=" + id1);
s = pst1.executeUpdate();
if (s == 0) {
System.out.println("Timer updated");
} else {
System.out.println("TImer not updated");
}
} catch (Exception e) {
System.out.println(e);
}
... // End of variables declaration
}
}
欢迎提出任何建议。谢谢,我使用mac OS X,但我发现了一个错误:
无法连接到SOCKS代理:连接被拒绝:连接
我打开:
系统首选项->网络->高级->代理->代理
这就解决了问题。在堆栈跟踪中,我发现错误无法连接到SOCKS代理:连接被拒绝:连接 我想是因为系统代理设置,连接被拒绝了。移除代理,它将像符咒一样工作。要删除Windows 10中的代理设置, 打开设置-单击网络和互联网-单击代理 在手动代理设置中,取消选中使用代理服务器
谢谢大家。您能提供完整的堆栈跟踪吗?是哪一个?连接被拒绝?还是空指针异常?袜子在哪里变得更时髦?问题是什么?谢谢大家,我会尽力解决的。我删除了代理设置。从stacktrace了解到无法连接到SOCKS代理:连接被拒绝:连接关于SOCKS代理,除了您奇怪的标题之外,您没有任何问题。不清楚你在问什么。在你的问题中,堆栈跟踪中没有这样的错误。
package privacysensor;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import javax.swing.JOptionPane;
public class Sensors extends javax.swing.JFrame {
/**
* Creates new form Sensors
*/
String s1 = "", s2 = "", s3 = "", s4 = "", s5 = "", s6 = "", s7 = "", s8 = "", s9 = "";
DBConnect c = new DBConnect();
DateFormat df = new SimpleDateFormat("hh:mm a");
Calendar cal1 = Calendar.getInstance();
org.jdesktop.application.ResourceMap resourceMap =
org.jdesktop.application.Application.getInstance(
privacysensor.PrivacySensorApp.class).getContext().getResourceMap(Sensors.class);
Class1 x = new Class1();
int id, id1;
public Sensors() {
initComponents();
try {
id = x.idgeneration();
id1 = x.Tidgeneration();
Connection c1 = c.getConnection();
Connection c2 = c.getConnection();
PreparedStatement pst = c1.prepareStatement("update sensors set status='Offline' where id=" + id);
int s = pst.executeUpdate();
if (s == 0) {
System.out.println("Not updated");
} else {
System.out.println("Updated");
}
PreparedStatement pst1 = c2.prepareStatement("update timing set status='Offline' where id=" + id1);
s = pst1.executeUpdate();
if (s == 0) {
System.out.println("Timer updated");
} else {
System.out.println("TImer not updated");
}
} catch (Exception e) {
System.out.println(e);
}
... // End of variables declaration
}
}