java - Error "cannot find symbol" for Class Connection and Class Statement -
java - Error "cannot find symbol" for Class Connection and Class Statement -
i'm using glassfish, maven , commmand line host project.
i created jdbc database in glassfish , i'm trying create table in java-ee file:
package edu.ndnu.arivera; import javax.sql.*; import javax.annotation.resource; public class dbcreate{ @resource(name="jdbc/arivera") datasource ds; public void connectandquerydb(string username, string password) { connection con = ds.getconnection(); statement stmt = con.createstatement(); stmt.executequery("create table voter (firstname varchar(30),lastname varchar(30), address varchar(30), city varchar(30), state varchar(30), zip varchar(30), phone varchar(30), affil varchar(30))"); con.close(); } }
however error:
[error] symbol: class connection [error] location: class edu.ndnu.arivera.dbcreate [error] /home/student/contestedcounty/src/main/java/edu/ndnu/arivera/dbcreate.java:[12,1] cannot find symbol [error] symbol: class statement [error] location: class edu.ndnu.arivera.dbcreate
i'm not sure i'm doing wrong.
the classes java.sql.connection
, java.sql.statement
. importing javax.sql.*
, cannot find these classes.
if want utilize classes bundle other current bundle or java.lang
, need import classes (eg import java.sql.connection
, import java.sql.statement
). ide have suggested you.
java maven java-ee jdbc glassfish
Comments
Post a Comment