This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
this is a jsp file . look at the line with code-> Statement st=con.createStatement(); in the below example. the error is "cannot convert from java.sql.Statement to com.mysql.jdbc.Statement
please help me with it. thanks
<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
It's really, really bad practice to put application logic into JSPs and our local Defender of the Faith will probably be along to chastise you soon.
It's also really, really bad practice to build up SQL requests from string concatenations. That's precisely how Sony got eaten.
It's not even a good idea to create connections by brute force in J2EE webapps, as far as that goes. Pooled connections are usually more efficient.
But the fatal offence here is that you shouldn't be using the mysql-specific version of "Statement" class. The only time you ever should use a DBMS vendor's proprietary classes in JDBC is if you have no choice in order to access a vendor-specific feature. Normally a class like com.mysql.jdbc.Statement implements the java.sql.Statement interface and that's the touch-point you should be using.
An IDE is no substitute for an Intelligent Developer.