· 6 years ago · Jul 14, 2019, 02:06 PM
1//der Fehler
2
3java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
4[MySQL] §4Fehler: §cCould not create connection to database server. Attempted reconnect 3 times. Giving up.
5 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
6 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
7 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
8 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
9 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
10 at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:905)
11 at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:830)
12 at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
13 at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
14 at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
15 at java.sql.DriverManager.getConnection(DriverManager.java:664)
16 at java.sql.DriverManager.getConnection(DriverManager.java:247)
17 at radiopower.de.Main.MySQL.connect(MySQL.java:43)
18 at radiopower.de.Main.Load.main(Load.java:28)
19Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'CEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
20 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
21 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
22 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
23 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
24 at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
25 at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
26 at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
27 at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2243)
28 at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2267)
29 at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
30 at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:868)
31 ... 8 more
32Der Bot wurde erfolgreich gestartet
33
34
35//
36
37package radiopower.de.Main;
38
39import com.github.theholywaffle.teamspeak3.TS3Api;
40import com.github.theholywaffle.teamspeak3.TS3Config;
41import com.github.theholywaffle.teamspeak3.TS3Query;
42import radiopower.de.Events.*;
43
44import java.sql.ResultSet;
45import java.sql.SQLException;
46import java.util.logging.Level;
47
48public class Load {
49
50 public static final TS3Config config = new TS3Config();
51 public static final TS3Query query = new TS3Query(config);
52 public static final TS3Api api = new TS3Api(query);
53 public static MySQL mySQL;
54
55 public static void main(String[] args){
56 config.setHost("-----");
57 config.setFloodRate(TS3Query.FloodRate.UNLIMITED);
58 config.setDebugLevel(Level.ALL);
59 query.connect();
60 api.selectVirtualServerById(---);
61 api.login("------");
62 api.setNickname("----");
63 mySQL = new MySQL("localhost","root","Passwort","DB");
64 mySQL.connect();
65 Live.loadEvents();
66 Streamplan.loadEvents();
67 Help.loadEvents();
68 Rp.loadEvents();
69 Info.loadEvents();
70 System.out.println("Der Bot wurde erfolgreich gestartet");
71 }
72
73}
74
75
76
77
78package radiopower.de.Main;
79
80
81import java.sql.Connection;
82import java.sql.DriverManager;
83import java.sql.ResultSet;
84import java.sql.SQLException;
85
86
87public class MySQL {
88
89 public static Connection con;
90
91 String host;
92 String name;
93 String password;
94 String database;
95
96 public MySQL(String host, String user, String pw, String db) {
97 this.host = host;
98 this.name = user;
99 this.password = pw;
100 this.database = db;
101 }
102
103 public void connect() {
104 if(!isConnected()) {
105 try {
106 con = DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database + "?autoReconnect=true", name, password);
107 System.out.println("[MySQL] Verbindung zur MySQL erfolgreich!");
108
109 } catch (SQLException e) {
110 e.printStackTrace();
111 System.out.println("[MySQL] §4Fehler: §c" + e.getMessage());
112
113 }
114
115 }
116 }
117
118 public void close() {
119 if(isConnected()) {
120 try {
121 con.close();
122 System.out.println("[MySQL] Verbindung zur MySQL beendet!");
123
124 } catch (SQLException e) {
125 e.printStackTrace();
126 System.out.println("[MySQL] §4Fehler: §c" + e.getMessage());
127
128 }
129 }
130 }
131
132 public boolean isConnected() {
133 return con != null;
134
135 }
136
137 public void createTable(String name, String table) {
138 try {
139 con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS " + name + "(" + table + ")");
140 } catch (SQLException e) {
141 e.printStackTrace();
142 }
143 }
144
145 public void update(String qry) {
146 if(isConnected()) {
147 try {
148 con.createStatement().executeUpdate(qry);
149 } catch (SQLException e) {
150 e.printStackTrace();
151 }
152 }
153 }
154
155 public ResultSet getResult(String qry) {
156 if(isConnected()) {
157 try {
158 return con.createStatement().executeQuery(qry);
159 } catch (SQLException e) {
160 e.printStackTrace();
161 }
162 }
163 return null;
164 }
165
166 }