Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   Problems connecting jsp with MySQL database (http://www.go4expert.com/forums/connecting-jsp-mysql-database-t10084/)

genji 17Apr2008 03:17

Problems connecting jsp with MySQL database
hey guys

I've been trying to connect this jsp site with MySQL database for a school assignment and I just can't seem to get it to work. It's getting really really frustrating because I have copied my friend's code(which does work on his pc) and for some odd reason it just won't work on my pc!(yes i changed the database names/passwords/table names in the code)

I'm using Tomcat, MySQL front and MySQL server(same as my classmates).

Here's the code:

<head><title>Enter to database</title></head>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import = "java.awt.*" %>
<%@ page import = "java.awt.event.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "javax.swing.*" %>

    String queryString =null;
    PreparedStatement statement = null;
    Connection connection = null;
    ResultSet myData = null;
        Object ophalen;
        try {
            connection = DriverManager.getConnection
                    ("jdbc:mysql://localhost:3306/friends","root", "root");
            queryString = "SELECT * from tableoffriends" ;
            statement = connection.prepareStatement(queryString);

            myData = statement.executeQuery();

                        //zet alles in een variable en roep de variable onder op , stayli <%= variable


                catch(Exception SQLException) {

 <%= myData.getString(1) %>
 <%= myData.getString(2) %>
 <%= myData.getString(3) %>


genji 17Apr2008 04:16

Re: Problems connecting jsp with MySQL database
please help!

All times are GMT +5.5. The time now is 15:57.