LAN 2コンピューターで接続します。最初の pc はサーバーで、wamp サーバーをインストールします。そして、ブラウザでクライアントPCからそのサーバーを使用しています。しかし、私のJavaプログラムはサーバーに接続します。エラーはありません。助けて。ここに私のコードが切り取られています:
public class dataconnection {
public Connection getDBConnection() throws Exception {
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
String sURL = "jdbc:mysql://192.168.0.102:8081/db_name?useUnicode=true&characterEncoding=UTF-8";
String sUserName = "root";
String sPwd = "pass";
conn = DriverManager.getConnection(sURL, sUserName, sPwd);
return conn;
}
}
ここにあります:app.class
try {
dataconnection datacon = new dataconnection();
String customername = jTextField1.getText();
String organization = jTextField2.getText();
String serialkey = jTextField3.getText();
GetMacAddress();
String sql = "Select data from cols where id='" + id + "'";
Connection con = datacon.getDBConnection();
PreparedStatement ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
JOptionPane.showMessageDialog(null,
"Invalid",
"Error",
JOptionPane.ERROR_MESSAGE);
}
そうでなければ{ブラブラ...}