• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

database connection with jstl

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, i've completely restarted my work. I've decided to use Struts.
Bye
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, not bad. Wishing you luck with Struts.
cheers.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic