Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

database connection with jstl  RSS feed

 
Mike Floyd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i've a little problem with a database connection.
When i use jdbc script the code works else when i try with jstl sql tags, the result is different.
The java code is:
String url = "JDBC DBC:Sofia";
String db_driver ="sun.jdbc.odbc.JdbcOdbcDriver";
Connection con = DB_bean.connetti(db_driver, url);
this works correctly;

the jstl tags are:
<sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver"
url="JDBC DBC:Sofia" var="db"/>
<sql:update dataSource="db" var="count">
INSERT INTO anagrafica VALUES ("luigi", "parigi")
</sql:update>

and tomcat says me that:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"

how i can to do?
bye
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you write java code to connect that database?
 
Mike Floyd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, this is the bean code that connect to database:
public class DB_bean {

public Connection connetti(String DN, String db) throws SQLException, ClassNotFoundException {
Class.forName(DN);
Connection conn = DriverManager.getConnection(db);
return conn;
}
}

but i prefere to use only jstl tags, excuse me for my english!
bye


but i prefere do not use java code
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you want to use JSTL SQL tags? it is not at all recommended though. For prototyping its fine.

just to add:
Doing DB stuff in jsp is a sin.

cheers.
[ February 01, 2005: Message edited by: Adeel Ansari ]
 
Mike Floyd
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i've completely restarted my work. I've decided to use Struts.
Bye
 
Babar Qadri
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, not bad. Wishing you luck with Struts.
cheers.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!