Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • 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.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 {
try {
myBroker = new DbConnectionBroker("", "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 {
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.out.println ("SQL Exception in doPost");
finally {
if(stmt != null) {
catch(SQLException e) {
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
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!