0

Why I'm getting error "cannot find symbol: createStatement()"? My goal is to create a t1 Tab object in a TestClass and calls t1.Cr() with a String parameter. I'm not forgetting the import java.sql.*;

public void Cr() throws Exception {
        try {
            ConexaoPlus con = new ConexaoPlus();
            con.conect();
            Statement st = con.createStatement();
            st.execute("CREATE TABLE " + getName() + "();");
            st.execute("DROP TABLE " + getName() + "();");
            st.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Thanks in advance!

eightShirt
  • 1,457
  • 2
  • 15
  • 29
  • 1
    The message means that there is no metod named createStatement() in the class ConexaoPlus. You're the only one to know what this class is, since it's not a standard class. Look up its code or documentation. – JB Nizet Sep 28 '15 at 19:53
  • Can you share the source (or at least API/javadoc) of ConexaoPlus? – Mureinik Sep 28 '15 at 19:53

2 Answers2

1

A cannot find symbol error may occur for many reasons. You can read this post.

From what I see from the code you have provided, your class ConexaoPlus does not contain the method createStatement() or you might have not defined it.

java sql packages will have these methods already defined which you can use. For more help you will need to share the class ConexaoPlus.

Community
  • 1
  • 1
Satyam Roy
  • 336
  • 4
  • 18
0

This worked for me.

import java.sql.Statement;