Seguindo os passos do curso, mas da erro de conversão. Não entendo.
package br.com.unip.pedidosPizzaria.dao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class TesteConexao {
public static void main(String[] args) {
CriaConexao criaConexao = new CriaConexao();
Connection connection = criaConexao.recuperaConexao();
Statement stm = connection.createStatement();
stm.execute("select ID, ID_PEDIDO, VL_PRODUTO, NOME FROM TB_ITEM ");
ResultSet rst = new stm.getResultSet();
while(rst.next()) {
Integer id = rst.getInt("ID");
System.out.println(id);
Integer id_pedido = rst.getInt("ID_pedido");
System.out.println(id_pedido);
double valor = rst.getDouble("VL_PRODUTO");
System.out.println(valor);
String nome = rst.getString("NOME");
System.out.println(nome);
}
}
}
package br.com.unip.pedidosPizzaria.dao;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
public class CriaConexao {
public Connection recuperaConexao() throws SQLException {
return DriverManager
.getConnection("jdbc:sqlserver://localhost:1433;/databaseName=PIZZARIA", "sa", "senha");
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
criaConexao cannot be resolved to a type
connection cannot be resolved to a type
stm cannot be resolved to a type
at br.com.unip.pedidosPizzaria.dao.TesteConexao.main(TesteConexao.java:15)