package mysql;
肥西ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
import java.sql.*;
/**
* @author xys
*/
public class ConnectMysql {
public static Connection getConnection() throws ClassNotFoundException, SQLException {
String url = "jdbc:mysql://localhost:3306/databaseName";
String user = "mysqluser";
String password = "password";
String driverClass = "com.mysql.cj.jdbc.Driver";
Connection connection = null;
Class.forName(driverClass);
try {
connection = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
}
if (connection != null) {
System.out.println("數(shù)據(jù)庫連接成功");
} else {
System.out.println("數(shù)據(jù)庫連接失敗");
connection.close();
}
return connection;
}
public void getResult() throws ClassNotFoundException, SQLException {
// 實例化 Statement 對象
Statement statement = getConnection().createStatement();
// 要執(zhí)行的 Mysql 數(shù)據(jù)庫操作語句(增、刪、改、查)
String sql = "";
// 展開結果集數(shù)據(jù)庫
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
// 通過字段檢索
int id = resultSet.getInt("id");
String name = resultSet.getString("name");
// 輸出數(shù)據(jù)
System.out.println("ID : " +id);
System.out.println("name :" + name);
}
// 完成后需要依次關閉
resultSet.close();
statement.close();
getConnection().close();
}
}
瀏覽器進入路由器管理地址:192.168.1.1--輸入賬號、密碼進入管理界面
2
單擊左側的【DHCP】--客戶端列表
3
好了,所有設備的IP地址盡在眼底
END
借助小軟件
上面的方法簡單吧,當然你如果手頭有360,也可以這么搞
先打開【家庭網(wǎng)絡管理】
登錄你的路由器后,單擊【有線、無線設備】
好了,是不是更加清晰?
直接給你java關于telnet的一個例子
public?class?Main?{????public?static?void?main(String[]?args)?{????????try?{
TelnetClient?telnetClient?=?new?TelnetClient("vt200");??//指明Telnet終端類型,否則會返回來的數(shù)據(jù)中文會亂碼
telnetClient.setDefaultTimeout(5000);?//socket延遲時間:5000ms
telnetClient.connect("127.0.0.1",23);??//建立一個連接,默認端口是23
InputStream?inputStream?=?telnetClient.getInputStream();?//讀取命令的流
PrintStream?pStream?=?new?PrintStream(telnetClient.getOutputStream());??//寫命令的流
byte[]?b?=?new?byte[1024];????????????int?size;
StringBuffer?sBuffer?=?new?StringBuffer(300);????????????while(true)?{?????//讀取Server返回來的數(shù)據(jù),直到讀到登陸標識,這個時候認為可以輸入用戶名
size?=?inputStream.read(b);????????????????if(-1?!=?size)?{
sBuffer.append(new?String(b,0,size));????????????????????if(sBuffer.toString().trim().endsWith("login:"))?{????????????????????????break;
}
}
}
System.out.println(sBuffer.toString());
pStream.println("exit");?//寫命令
pStream.flush();?//將命令發(fā)送到telnet?Server
if(null?!=?pStream)?{
pStream.close();
}
telnetClient.disconnect();
}?catch?(SocketException?e)?{????????????//?TODO?Auto-generated?catch?block????????????e.printStackTrace();
}?catch?(IOException?e)?{????????????//?TODO?Auto-generated?catch?block????????????e.printStackTrace();
}
}
}
本文題目:java連接網(wǎng)絡設備代碼 java networkinterface
文章分享:http://vcdvsql.cn/article18/doicsgp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、網(wǎng)站制作、企業(yè)網(wǎng)站制作、營銷型網(wǎng)站建設、網(wǎng)站建設、品牌網(wǎng)站設計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)