Need help creating SQL query

View: New views
2 Messages — Rating Filter:   Alert me  

Need help creating SQL query

by vieraci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This statement:

Statement stmt = myConn.createQuery();

I get this error in the popup where the red (!) is displayed to the left of
the statement in the Netbeans 6.1 IDE

createQuery(java.lang.string) in javax.persistence.EntityManager cannot be
applied to incompatible types
Found javax.persistence.EntityManager.createQuery
required: com.mysql.jdbc.Statement

Driver is mysql-connector-java-5.1.5 (Revision ${svn revision})
myConn is an EntityManager bean
Even if I give the complete name (com.mysql.jdbc.Statement stmt = ) is same
error.

Why is this so ?

--
View this message in context: http://www.nabble.com/Need-help-creating-SQL-query-tp16993050p16993050.html
Sent from the Netbeans - Dev mailing list archive at Nabble.com.


Parent Message unknown Re: Need help creating SQL query

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- vieraci <vince@...> wrote:

>
> This statement:
>
> Statement stmt = myConn.createQuery();
>
> I get this error in the popup where the red (!) is displayed to the left of
> the statement in the Netbeans 6.1 IDE
>
> createQuery(java.lang.string) in javax.persistence.EntityManager cannot be
> applied to incompatible types
> Found javax.persistence.EntityManager.createQuery
> required: com.mysql.jdbc.Statement
>
> Driver is mysql-connector-java-5.1.5 (Revision ${svn revision})
> myConn is an EntityManager bean
> Even if I give the complete name (com.mysql.jdbc.Statement stmt = ) is same
> error.
>
> Why is this so ?
>

Please read the descriptions of the forums when posting in Nabble. This list is for development
of the NetBeans IDE. Your issue is caused by the fact that Query is not a Statement. You need to
be using the correct APIs together. See the regular JavaDocs in the JDK for package java.sql and
then see the EE JavaDocs and see javax.persistence. What you are doing is the same as one trying
to do this:

java.sql.Connection con = new String("hello");

It just doesn't work nor make sense. I'm just getting to the point that this is a regular Java or
any other language rule, and not trying to be rude...could seem that way. The types must match.

Wade


==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org