LinusHuck
LinusHuck
Explore posts from servers
JCHJava Community | Help. Code. Learn.
Created by AyoWut? on 10/6/2024 in #java-help
Creating an object of an entire class?
13 replies
JCHJava Community | Help. Code. Learn.
Created by AyoWut? on 10/6/2024 in #java-help
Creating an object of an entire class?
Since he is at the start of java i would say not also @AllArgsConstructor is a part of lombok https://projectlombok.org/features/
13 replies
JCHJava Community | Help. Code. Learn.
Created by LinusHuck on 5/10/2024 in #java-help
Problems with sql
Ok thanks
45 replies
JCHJava Community | Help. Code. Learn.
Created by LinusHuck on 5/10/2024 in #java-help
Problems with sql
is there a thing like close after 5sec if not used?
45 replies
JCHJava Community | Help. Code. Learn.
Created by LinusHuck on 5/10/2024 in #java-help
Problems with sql
lets say i dont close it somewhere will it hurt?
45 replies
JCHJava Community | Help. Code. Learn.
Created by LinusHuck on 5/10/2024 in #java-help
Problems with sql
public Connection getConnection()
{
try
{
//Load database driver class
if(this.link == null || this.link.isEmpty())
{
this.link = "com.mysql.cj.jdbc.Driver"; //Updated driver class name
}
Class.forName(this.link);

//Establish a new connection
return DriverManager.getConnection(this.url, this.user, this.password);
}
catch(SQLException | ClassNotFoundException throwable)
{
throwable.printStackTrace();
Logger.info(CoreModule.getPlugin(), "MySQLDatabase", "There is a problem in the MySQL database connection!");
}
return null;
}
public Connection getConnection()
{
try
{
//Load database driver class
if(this.link == null || this.link.isEmpty())
{
this.link = "com.mysql.cj.jdbc.Driver"; //Updated driver class name
}
Class.forName(this.link);

//Establish a new connection
return DriverManager.getConnection(this.url, this.user, this.password);
}
catch(SQLException | ClassNotFoundException throwable)
{
throwable.printStackTrace();
Logger.info(CoreModule.getPlugin(), "MySQLDatabase", "There is a problem in the MySQL database connection!");
}
return null;
}
so like this?
45 replies