hola creo que tengo el código igual que el del instructor, pero al correr el programa me da error, supongo que será problemas de la versión
package com.alura.jdbc.controller;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
public class ProductoController {
public void modificar(String nombre, String descripcion, Integer id) {
// TODO
}
public void eliminar(Integer id) {
// TODO
}
public List<?> listar() throws SQLException {
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost/control_de_stock?useTimeZone=true&serverTimeZone=UTC",
"root", "root1234");
Statement statement = con.createStatement();
boolean result = statement.execute("SELECT ID, NOMBRE, DESCRIPCION, CANTIDAD FROM PRODUCTO");
System.out.println(result);
con.close();
return new ArrayList<>();
}
public void guardar(Object producto) {
// TODO
}
}
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRODUCTO' at line 1
at com.alura.jdbc.view.ControlDeStockFrame.cargarTabla(ControlDeStockFrame.java:215)
at com.alura.jdbc.view.ControlDeStockFrame.configurarTablaDeContenido(ControlDeStockFrame.java:59)
at com.alura.jdbc.view.ControlDeStockFrame.<init>(ControlDeStockFrame.java:46)
at com.alura.jdbc.ControlDeStockMain.main(ControlDeStockMain.java:10)
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PRODUCTO' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:764)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:648)
at com.alura.jdbc.controller.ProductoController.listar(ProductoController.java:25)
at com.alura.jdbc.view.ControlDeStockFrame.cargarTabla(ControlDeStockFrame.java:213)
... 3 more