• 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

Help !!!!!!! Connection problems from you know where!

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had originally posted this in the servlets section but got no response & I really need to get this straightened asap. So here goes:
I am using the dbConnection Broker with some servlets Im writing for a site. Testing them on my local machine works fine but when I load them to the server I keep getting a null pointer exception at every line that references the broker. I have the class file in the folders : com/javaExchange/dbConnectionBroker/ packaged just as I am using it on my local machine in both the lib folder on the server (has all the jar files) & the web-inf/classes folder (has the servlet files). The servlets run flawlessly when I use standard connection methods but blows up when using the broker. Any help would be much appreciated. Here is a sample of the code Im using this in: Ive pulled out the extranious code to make this easier to read. It isnt the problem (runs fine w/o the broker using standard connection) its the broker.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.javaexchange.dbConnectionBroker.*;
import java.sql.*;
public class logIn extends HttpServlet {
DbConnectionBroker myBroker;
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
myBroker = new DbConnectionBroker("org.gjt.mm.mysql.Driver", "jdbc:mysql://localhost/[dbName]", "[userName]", "[password]", 2, 7, "/log/error.log", 1.0);
}
catch (IOException e5) {
System.err.println (e5.getMessage());
}
}
Statement stmt = null;
Connection conn = null;
PrintWriter out;

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
try
{
int x = 1;
int trigger1 = 0;
String userName = null;
String passWord = null;
String emailAddy = null;
conn = myBroker.getConnection();
userName = req.getParameter("userName").toUpperCase();
passWord = req.getParameter("passWord").toUpperCase();
stmt = conn.createStatement();
res.setContentType ("text/html");
out = res.getWriter();
//Other Code here
}
catch (SQLException sqle)
{
System.err.println(sqle.getMessage());
System.out.println ("SQL Exception in doPost");
}
finally {
try{
if(stmt != null) {
stmt.close();
}
}
catch(SQLException e) {
};
myBroker.freeConnection(conn);
}
out.close();
}
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
doPost(req, res);
}
}
I put the code back the way it was using standard connection methods (not using the broker) & it works just fine........I just dont see what Im doing wrong here. Ive quadruple checked every variable from the one that works to the one that doesnt & everything is identical.............THANKS FOR ANY HELP
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic