You are not logged in.

  • Login

[Bukkit-Plugin] Sql link error

Bitte besucht unser neues Forum unter https://forum.nitrado.net | Please visit our new Forum at https://forum.nitrado.net

Dear visitor, welcome to Nitrado.net Prepaid Gameserver Community-Support - Archiv. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Saw22

User / Kunde

  • "Saw22" started this thread

Posts: 4

  • Send private message

1

Saturday, November 15th 2014, 7:06pm

Sql link error

moin liebe comunity
ich habe ein problehm mit meim plugin es sagt das keine verbindung zum sql server hergestelt werden kann

hier meine MySQL classe

package me.red.sq;


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

public class MySQL {

	private String Host;
	private int port;
	private String user;
	private String password;
	private String database;
	private Connection conn;
	public MySQL() throws Exception{
File file = new File("plugins/sq/","database.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
String db = "database.";
cfg.addDefault(db + "host","localhost");
cfg.addDefault(db + "port","3306");
cfg.addDefault(db + "user","test");
cfg.addDefault(db + "password","Asdfasdf1");
cfg.addDefault(db + "database","test");
cfg.options().copyDefaults(true);
try {
cfg.save(file);
} catch (IOException e) {
e.printStackTrace();
}
this.Host = cfg.getString(db+"host");
this.port = cfg.getInt(db+"port");
this.user = cfg.getString(db+"user");
this.password = cfg.getString(db+"password");
this.database = cfg.getString(db+"database");

this.openConnection();
	}

public Connection openConnection() throws Exception {
	
Class.forName("com.mysql.jdbc.Driver");

Connection conn = DriverManager.getConnection("jdbc:mysql://" + this.Host + ":" + this.port + "/" + this.database, this.user, this.password);
this.conn = conn;
return conn;
	



}

public Connection getConnection(){
	return this.conn;
}

public boolean hasConnection(){
	try {
return this.conn != null || this.conn.isValid(1);
	} catch (SQLException e) {

return false;
	}
}

public void queryUpdate(String query){
	Connection conn = this.conn;
	PreparedStatement st = null;
	try {
st = conn.prepareStatement(query);
st.executeUpdate();
	} catch (SQLException e) {
System.err.println("failled to update'"+query+"'.");
	}finally{
this.closeRessources(null, st);
	}
	
}
public void closeRessources(ResultSet rs, PreparedStatement st){
	
	if(rs!=null){
try {
rs.close();
} catch (SQLException e) {
}
	}
	if(st!=null){
try {
st.close();
} catch (SQLException e) { 
}
	}
}
public void closeConnection(){
	try {
this.conn.close();
	} catch (SQLException e) {
e.printStackTrace();
	}finally{
this.conn = null;
	}
	}
	
}


der minecraft server und der sql server sind auf dem gleichen root
danke im voraus für eure hilfe

This post has been edited 5 times, last edit by "Saw22" (Nov 16th 2014, 1:10am)


KingDome24

Moderator im Ruhestand

  • "KingDome24" is male

Posts: 7,437

Location: Österreich

Occupation: Schüler

Thanks: 237

  • Send private message

2

Saturday, November 15th 2014, 7:07pm

Wenn ich geholfen hab, freu ich mich über eine Danksagung.

Saw22

User / Kunde

  • "Saw22" started this thread

Posts: 4

  • Send private message

3

Saturday, November 15th 2014, 7:10pm


Anno35

User / Kunde

Posts: 1,223

Thanks: 3

  • Send private message

4

Saturday, November 15th 2014, 7:18pm

Sind die MySQL Logindaten alle richtig eingegeben?

Saw22

User / Kunde

  • "Saw22" started this thread

Posts: 4

  • Send private message

5

Saturday, November 15th 2014, 7:29pm

Sind die MySQL Logindaten alle richtig eingegeben?
ja alles korreckt

th3t0myb0y

User / Kunde

  • "th3t0myb0y" is male

Posts: 214

Location: Nordrhein-Westfalen

Occupation: Schüler

  • Send private message

6

Saturday, November 15th 2014, 11:06pm

1. Ganze Fehlermeldung
2. Code in Code-BBCode-Tags oder die für die entsprechende Sprache, also zum Beispiel die Java-BBCode-Tags für Java.
3. Variablen schreibt man im LowerCamelCase
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."
~Linus Torvalds

Saw22

User / Kunde

  • "Saw22" started this thread

Posts: 4

  • Send private message

7

Sunday, November 16th 2014, 1:02am

1. Ganze Fehlermeldung
2. Code in Code-BBCode-Tags oder die für die entsprechende Sprache, also zum Beispiel die Java-BBCode-Tags für Java.
3. Variablen schreibt man im LowerCamelCase

ich weis nicht wie man die BBCode tags vergibt

die erro meldung

Source code

1
2
failled to start sql servic(Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.).


mit php myadmin kannn ich jedoch auf die sql datenbank zu greifen deshalb vermute ich ein fehler im code

This post has been edited 2 times, last edit by "Saw22" (Nov 16th 2014, 3:50pm)


Bitte besucht unser neues Forum unter https://forum.nitrado.net| Please visit our new Forum at https://forum.nitrado.net