无法连接到SOCKS代理:连接被拒绝:连接
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法连接到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.
以下是数据库连接代码。
public class DBConnect {
// System.out.println("MySQL Connect Example.");
public static Connection getConnection() {
Connection conn = null;
String url = "jdbc:mysql://127.0.0.1:3306/";
String dbName = "networkcoding";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "xampp123";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url + dbName, userName, password);
System.out.println("Connected to the database "+dbName);
//conn.close();
//System.out.println("Disconnected from database");
} catch (Exception e) {
System.out.println("Not Connected to the database - "+dbName);
e.printStackTrace();
}
return conn;
}
public static void main(String arg[]){
DBConnect.getConnection();
}
}
错误在代码的以下部分内:
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,我收到了错误:
Can't connect to SOCKS proxy:Connection refused: connect
。
我打开了:
系统首选项 - >网络 - >高级 - >代理 - >未选中SOCKS代理
这解决了这个问题。
以上是关于无法连接到SOCKS代理:连接被拒绝:连接的主要内容,如果未能解决你的问题,请参考以下文章
Ejabberd 无法连接到“localhost”:3306:错误,“连接失败:连接被拒绝”
initctl:无法连接到 Upstart:无法连接到套接字 /com/ubuntu/upstart:连接被拒绝