Looks like you used the example right out of the book which uses a
pre-defined datasource called "cfsnippets." The example assumes that this
datasource has already been defined. In order for it to work you have to
have a JDBC datasource named cfsnippets in the JMC.
If you are using the JDBC to odbc bridge, you have to have an odbc
datasource named "cfnippets."
-----Original Message-----
From: Rog�rio Garibalde Miranda [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 1:45 PM
To: JRun-Talk
Subject: Error JDBC
I get a error when execute this code:
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%
try {
InitialContext ic = new InitialContext();
DataSource dataSource (DataSource)ic.lookup("java:comp/env/jdbc/cfsnippets");
Connection con = dataSource.getConnection();
Statement stmt = con.createStatement();
Enumeration fieldNames = session.getAttributeNames();
String formfields = "";
String values = "";
while (fieldNames.hasMoreElements()) {
String name = (String)fieldNames.nextElement();
String key = (String)session.getAttribute(name);
String val = request.getParameter(key);
if (formfields.equals(""))
formfields = key;
else
formfields += ", " + key;
if (values.equals(""))
values = "'" + val + "'";
else
values += ", " + "'" + val + "'";
}
String sql = "INSERT INTO " + "Courses" + "(" + formfields + ") VALUES
(" + values + ")";
stmt.execute(sql);
stmt.close();
con.close();
} catch (SQLException ex) {
throw new ServletException(ex.getMessage());
}
%>
the error:
Exception thrown on line '9' from page
'E:\\Inetpub\\wwwroot\\projetosjsp\\demop\\ban_EntryAction.jsp'.
javax.naming.NameNotFoundException: cfsnippets not found
at allaire.jrun.LocalContext.lookup(../LocalContext.java:214)
at allaire.jrun.LocalContext.lookup(../LocalContext.java:236)
at allaire.jrun.LocalContext.lookup(../LocalContext.java:236)
at allaire.jrun.LocalContext.lookup(../LocalContext.java:236)
at allaire.jrun.LocalContext.lookup(../LocalContext.java:195)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at
jrun__projetosjsp__demop__ban_EntryAction2ejsp26._jspService(jrun__projetosj
sp__demop__ban_EntryAction2ejsp26.java:51)
at
allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
at
allaire.jrun.session.JRunSessionService.service(../session/JRunSessionServic
e.java:1082)
at
allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
at
allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDis
patcher.java:89)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
at
allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
at
allaire.jrun.jrpp.ProxyEndpoint.run(../jrpp/ProxyEndpoint.java:388)
at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
but cfsnippets datasource exists.
anybody can help me?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists