0

I'm trying to connect a DB from Postgres with a program in Java. I'm including this code:

Class.forName(driver);
Connection con = DriverManager.getConnection(connectString, user , password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM students");

But I'm getting this erros in Statemen and stmt.excuteQuery:
With Statement: incompatible types. Required: java.beans.Statement. Found: java.sql.Statement
With .executeQuery: Cannot find symbol. Symbol: method executeQuery (java.lang.String). Location: class java.beans.Statement

In all the tutorials they include this code and they don't seem to have any problem. Any idea what can I do?

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by prachi69
0

I've this "imports"

import java.beans.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
2

The import java.beans.Statement is wrong . You have to import java.sql.Statement .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.