Connect to MySQL without JDBC

Hello to everyone,
Is there any way i can connect to a MySQL database without using JDBC? My web host does not support Java unless i go and buy a dedicated Server package which costs a small fortune so i am trying to find a work-around solution. Is there any way i can access a database by combining Java (locally) and PHP on server-side to get data out of the database and back to the Java piece of software?
Thanks to everyone who might see or reply to this post

Hello deeprave, thanks for replying so quick.
So i guess this is not the best thing to do then. Please allow me to state my problem clearly . Maybe someone might have an answer to my issue. I want to be able to connect Java software on a web server. As deeprave correctly spotted, this can be done using Sockets. Indeed, i have my program connecting to the server.
On my website, i ask users to register themselves in the user database (using standard PHP). Users are then able to log in their account and do stuff. This works fine through the browser.
Issue is at the point where i want my Java software sitting locally on the users machine to be able to connect to the server and authenticate the user. If a user is not registered, the software wont be able to operate (or at least enable user do specific actions). If anyone has any ideas that might help i would be grateful if he/she shares them with me. I am approaching my deadline for submitting my 3rd ear project and i am a bit worried...
Thanks a lot, and excuse me for the long question

Similar Messages

  • Connection to mySQL via jdbc

    I'm currently programming a GUI to access a database. Therefore I executed a query, which worked fine. But when I tried to exit my program with
    System.exit(0)my DOS-Prompt crashes without exiting.
    Now I tried it with a kind of minimalistic Connection like that:
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/stock");     
    conn.close();Here the same problem occurs, so it must be the Connection that causes the error.
    If I would exit the program right away after the Connection, that is
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/stock");     
    conn.close();
    System.exit(0);then the program exits properly. Unfortunately it doesn't make any sense to quit the program right after reading the data.
    So, as you can guess, I'm quite confused. I used the same driver and the same database in another program on the same computer, and it works fine. So I'm left totally clueless.
    I'm not using a special programming environment, I just write my code using UltraEdit. I've got installed Java 1.4.0 on my machine.
    Any help is very appreciated
    Martin

    I don't get any.
    It just crashes. There's neither an exception thrown nor any other error msg.

  • Connect to mysql without datasource

    Good day every body.
    Im sure this is possible but i dont know how.
    I need to connect to a mysql database without creating a
    datasourse.
    I need the query code please.. if i need to install a driver
    on the server or create a dynamic datasourse. i can..
    Regards

    > Well i want do create sites that can connect to a mysql
    server dynamically
    > from settings changed in the application.cfm file.
    > So that different people can just change there ip
    without having to create the
    > datasource.
    Well <cfquery> tags and <cfstoredproc> tags
    require a datasource, don't
    they.
    So how are you expecting to use them without one?
    You COULD - quite easily - just use Java to communicate with
    the JDBC
    drivers, which would not require a DSN being defined, but it
    would mean not
    using CF's in-built database interactivity tags.
    I don't really understand why you think it's bad to have a
    datasource? Can
    you expand on your idea so I understand what you're trying to
    achieve?
    Adam

  • MYSQL Without JDBC

    Is there a way to connect to a MYSQL database without using the JDBC driver?

    Like if I wanted to connect to the database using php in the java file like so:
    <?
    /*--------- DATABASE CONNECTION INFO---------*/
    $hostname="localhost";
    $mysql_login="myusername";
    $mysql_password="mypassword";
    $database="mydatabase";
    // connect to the database server
    if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
      die("Can't connect to database server.");    
    }else{
      // select a database
        if (!(mysql_select_db("$database",$db))){
          die("Can't connect to database.");
    ?> and then write the code to a table using java. Is that a possibility?

  • Problem connecting to Mysql using JDBC

    Hi Everyone,
    I am trying to connect Mysql ad java applet and I am using the Mysql jdbc connector.
    I Took the mysql-connector-java-5.0.8-bin.jar file and put that in the library of jdk.
    Now i used the following code to connect to the database using Netbeans.
    package testmysql;
    import java.sql.*;
    public class Main
    public static void main (String[] args)
    Connection conn = null;
    try
    String userName = "root";
    String password = "";
    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    finally
    if (conn != null)
    try
    conn.close ();
    System.out.println ("Database connection terminated");
    catch (Exception e) { /* ignore close errors */ }
    But it displays Cannot connect to database server
    thoughMysql server is running.
    Can anyone tell me wats the prob in this.
    thanks

    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    Is rpms the MySQL database?
    Is the database on the default port 3306?
    Is the MySQL JDBC JAR file in the classpath of the applet?
    newInstance() is not required to be invoked unless using <= JDK 2.0
    Replace:
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    with:
    catch (Exception e)
    System.err.println (e.getMessage());
    Edited by: dvohra09 on Apr 10, 2009 10:54 PM
    Edited by: dvohra09 on Apr 10, 2009 10:55 PM
    Edited by: dvohra09 on Apr 10, 2009 10:58 PM

  • HELP about How to connect with Database without JDBC ?

    Hello all,
    i have oracel8i database and my programe work fine with JDBC
    but now
    i want to connect my programe with database without using JDBC connection please any body tell me syntex for that,
    Class.forName("oracle.jdbc.driver.OracleDriver");
    databaseConnection = DriverManager.getConnection("??","arif","arif");
    i have user arif in my database and my computer name is "ABCD"
    Please help me,
    i m thanksfull,
    onlyforjava.

    Thanks i try it,
    url = "jdbc:oracle:thin:@ABCD:1521:" + sid;
    connection = DriverManager.getConnection(url,"arif","arif");
    but after that i got exception,
    java.sql.SQLException: Protocol violation
    Please help me,
    i m thanksfull.
    onlyforjava.

  • Connecting to MySQL with JDBC in Reports

    Hi,
    I need help connecting to a MySQL db through oracle reports using a jdbc connection.
    I have downloaded the MySQL JDBC driver:mysql-connector-java-3.0.17-ga-bin.jar.
    I can succesfully use it to connect if I write a simple java program. So I know the driver works.
    I have set it in my classpath & edited the jdbcpds.conf file by adding the following:
    <driver name = "mysql-merant"
    sourceDatabase = "other"
    subProtocol = "mysql"
    connectString = "mainProtocol:subProtocol://databaseName"
    class = "com.mysql.jdbc.Driver"
    connection = "oracle.reports.plugin.datasource.jdbcpds.JDBCConnectionHandling">
    </driver>
    When I try to connect, I get the following error, ERR 62002 failed to connect to the data source.
    What do I have to do to connect? Is there a way to directly give the connect string?
    I can connect to an oracle DB using a the Oracle drivers no problem, why does forms not accept the MySQL driver? What can I do to make this work?
    Any help would be appreciated.
    Michael Baran
    [email protected]

    Michael,
    there is a Reports forum here on OTN as well. Posting your question there might be a better chance.
    Frank

  • Problem connecting to MySQL thro Applet using JDBC

    Hi,
    I'm trying to use an applet to connect to MySQL thro JDBC. The applet, the IE client that loads the HTML, and MySQL all reside on the same machine. But I'm getting the following error:"ClassNotFoundException: com.mysql.jdbc.Driver". But I'm able to connect using a Java application and run and display SQL query results. Any ideas are highly appreciated. Here're are the two pieces of code:
    /****** Java Application *****/
    import java.sql.*;
    public class MySQL_App {
    public static void main(String args[]) {
              String url = "jdbc:mysql://localhost/test";
         try {
                   Class.forName("com.mysql.jdbc.Driver");
         catch(java.lang.ClassNotFoundException e) {
                   System.err.print("ClassNotFoundException: ");
                   System.err.println(e.getMessage());
    /****** Java Applet *****/
    import java.awt.*;
    import javax.swing.*;
    import netscape.javascript.*;
    import java.sql.*;
    public class MySQL_Applet extends JApplet {
         JSObject win;
         public void init() {
              win = JSObject.getWindow(this);
         public void callShowMessage() {
              String url = "jdbc:mysql://" + this.getDocumentBase().getHost() + "/test";
              String[] args = new String[1];
         args[0] = "" ;
         try {
              Class.forName("com.mysql.jdbc.Driver");
         catch(java.lang.ClassNotFoundException e) {
                   args[0] += "ClassNotFoundException " + e.getMessage() ;
         win.call("showMessage", args);
    }

    mmm i, think that may here we've 2 possibles answers:
    1) Did u read about "Applet Security"? my point is that you haven't acces to your local var "path" or "classpath".
    2) Maybe u didn't especificate the MySQl path in ur classpath;
    Check this 2 points

  • Connect to MySQL

    How can I create connection between mySQL and JDBC directly without ODBC. Does JDBC provide built-in mySQL driver ?
    Thank you very much

    yes. There is a type4 jdbc driver for mySql databases. It usually comes alongwith jdbc1.0 and 2.0 versions in a compressed file calles mysql_2_comp.jar. Or, you can download it from this site:
    http://www.worldserver.com/mm.mysql/
    This driver is also known as "mm driver".
    Amit.

  • Connecting with mysql

    hello
    how can i create a connection to mysql and postgresql databases in jdbc. without using odbc.
    thanks.

    You need to use a different driver. I assume you're using the jdbc-odbc bridge driver.
    For mysql, get the mm.mysql driver at http://mmmysql.sourceforge.net/
    For postgresql, go to http://jdbc.postgresql.org/
    I've only used the mysql driver, so I don't know the details of how to use the postgresql one.
    In general, you will have to do the following:
    1. download the jar file and put it in your classpath
    2. change the connection url string to conform with the format in the driver documentation.

  • Unable to connect to mysql using JSP servlet

    Respected Sir/Madam
    I have made a jsp application and use tomcat 4 and mysql .Whenever there is a db connection the application tries to connect.but then it throws exception
    java.sql.SQLException: Unable to connect to any hosts due to exception: java.net.ConnectException: Connection timed out: connect
    This error started occuring all of a sudden and i am not getting its root cause...Can anybody help me out of this...?
    I am having intranet. And one thing that amazed me was when I send request for that JSP page from different machine then it connected to db without any error..Only when I request that JSP page from my machine it is giving me this error.
    Please help..
    Waiting for your reply.
    Thanks and Regards

    Microsoft Telnet> open Oracleserver
    Connecting To Oracleserver...Could not open a
    connection to host: Connect failedYou need to run the exact command i gave you from the command line. There may not be a telnet server running on OracleServer, you are trying to connect to port 23 with the command above.
    run 'telnet Oracleserver 3306'
    If this does not work, try the same thing with the IP address instead of 'Oracleserver', you may have a name resolution issue.
    I didnt understood this .I also tried running this
    command from other machines where my application is
    running fine. But there also the same error.
    I gave proper URL and user name and password for mysql
    String dsnString="jdbc:mysql://Oracleserver/test";FYI - this will use the default port, I usually explicitly provide it (OracleServer:3306). Why don't you try the URL in the format I gave you above, including the user id and password?
    -Scott

  • Jakarta-tomcat-3.3.2 connection with mysql-4.1.12a-win32

    how do i connect to mysql using tomcat?
    i've set the class path = ".;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar;"
    without quotes
    i've copy the mysql-connector-java mysql-connector-java-3.1.10-bin.jar into the mentioned directory = "D:\j2sdk1.4.2_08\jre\lib\ext\"
    and my computer's mysql 's service is starting since my computer restart [i've checked it by right click desktop toolbar->Task Manager->Processes->mysqld-nt.exe..
    and i've used the code from :
    http://www.stardeveloper.com/articles/display.html?article=2003090201&page=4
    to test if my connection is active, my JdbcExample1.java file is located at D:\jakarta-tomcat-3.3.2\webapps\ROOT\WEB-INF\classes\com\example, so my source code is :
    package com.example;
    import java.sql.*;
    public class JdbcExample1 {
      public static void main(String args[]) {
    Connection con = null;
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql:///test", "root", "nothing");
    if(!con.isClosed())
    System.out.println("Successfully connected to MySQL server...");
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    } finally {
    try {
    if(con != null)
    con.close();
    } catch(SQLException e) {}
    when i compile the file using javac, it's fine, when i run it using java, it shows me this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: JdbcExample1 (wrong n
    ame: com/example/JdbcExample1)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    what have i missed out? anyone can u please help me? is my coding or setting in-accurate? thanks for reviewing my topics too

    I'm not sure why you have mentioned Tomcat, but you need to run the class with something like:
    java -classpath .;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1If you've correctly set the CLASSPATH environment variable then you can leave out the -classpath command line argument. Notice that you must specify the package of the class too.
    To compile this all correctly, you should do something like:
    mkdir classes
    javac -d classes JdbcExample1.javaand then run with
    java -classpath classes;D:\j2sdk1.4.2_08\jre\lib\ext\mysql-connector-java-3.1.10-bin.jar com.example.JdbcExample1

  • I can't connect to MySQL database from The JSP Standard Tag Library

    Hi All !
    I have a problem, please help me anybody !
    I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
    I have in folder�WEB-INF/lib� following files:
    antlr.jar
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-fileupload.jar
    commons-logging.jar
    commons-validator.jar
    jakarta-oro.jar
    jsf-api.jar
    jsf-impl.jar
    jstl.jar
    mysql-connector-java-3.1.13-bin.jar
    standard.jar
    struts.jar
    I'm using:
    NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
    Ent.Pack 20061020 Visual Wb Pack 061103
    OS WinXP SP2
    Java 1.5.0_10
    MySQL 5.0.18-nt
    1:<%@page contentType="text/html"%>
    2:<%@page pageEncoding="UTF-8"%>
    8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
    10:
    11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    12: "http://www.w3.org/TR/html4/loose.dtd">
    13:
    14: <sql:setDataSource var="ds"
    15: driver="com.mysql.jdbc.Driver"
    16: url="jdbc:mysql://localhost:3306/test"
    17: user="root"
    18: password="xxxx"/>
    19:
    20:
    21:<sql:query sql="select name, age from People" var="res"
    22: dataSource="${ds}"/>
    I have received report on mistake when entered code at the top:
    �/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
    I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
    After build and run I have received
    =========================================START=================================
    HTTP Status 500
    type Exception report:
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
    org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    =======================================END================================
    Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
    BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
    I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
    I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
    There is idea how can resolve this problem
    Thank you in advance ;)

    For all how have similar problem.
    Decision instead of these ways
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    it is necessary to indicate these
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

  • Error when connecting to mysql

    hi
    i m getting error when i want to connect with mysql
    the errors is below
    MySQL JDBC Driver not found ...
    Exception in thread "main" java.lang.ClassNotFoundException: org.gjt.mm.mysql.D
    iver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:130)
    at test.testDriver(test.java:42)
    at test.test(test.java:12)
    at test.main(test.java:127)
    plz help me
    kaleem

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A48&qt=%22java.lang.ClassNotFoundException%22&x=9&y=10

  • Mysql_connect "Lost connection to MySQL..." error 61

    A web developer is getting this error on a test web server of ours that is running 10.5.7 Server.
    "Warning: mysql_connect() function.mysql-connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 61 in..."
    I've seen other postings online for this error suggesting that the line containing 'bind-address 127.0.0.1' be commented out within /etc/my.conf... but this line doesn't exists on my installation.
    MySQL and php have been working well for other databases and developers. This is a newly created database.
    Has anyone else seen this error and found a fix?
    Thanks!

    This is more than likely a firewall problem on your users end. I just ran into this when moving my servers to a colocation. Everything was fine until i tried to connect to an outside database from the machines behind the new firewall. was set to allow 3306 in, but not out. And would connect without issues to localhost:/var/mysql/mysql.sock .
    from the machine trying to connect from try
    shell> telnet <servername> 3306
    should be able to login. if refused, then port is closed.
    -------

Maybe you are looking for

  • How can I hardwire transfer an iMovie project to another iPad

    Using a hardwire connection (and not iCloud or Airdrop) is there a way to transfer an iPad iMovie project directly from one iPad to another iPad so that the editing can continue on the second iPad? I can't use any wireless or bluetooth connection and

  • Missing episodes from TV series

    Hi all. I purchased a season ticket for 24 Season 8. I thought all episodes had downloaded, however, when I watched, episodes 18 and 19 are missing - arrrgh!! Now I can't watch the climactic episodes without these!! Sooo near the end! I can't see the

  • 16.10 16.9 which....

    Hi, I know nothing bout monitors I wanted to know what the differences are as I am about to buy a LCD/TFT 19" widescreen monitor This screen will be used for net surfing audio apps and dvd watching Kindest ,becca

  • OSB and BPEL Capacity Planning

    Guys, I am looking for a start point to begin a capacity planing of OSB and BPEL infrastructure. What are the parameters to take in account? How many managed servers? RAM? CPU? I know that some answers might be shallow because there are so many facto

  • Desactivation of photoshop and premiere elements

    Avant de formater mon disque dur, j'ai désinstallé photoshop et premiere elements sans les avoir désactivés. Comment faire pour les désactiver maintenant?