Connection to MySQL with JSP using Eclipse - mysql

I am a newbie and I wanted to know how build path and all mysql.jar to Eclipse so that I can use it for JSP and I have already made a dynamic web project configured with Tomcat. Only the database connection is not happening.
The error is:
java.sql.SQLException : No suitable driver found for jdbc:mysql://localhost/pj_company

You could create a lib folder your WEB-INF folder and paste the mysql driver jar in it, and then in eclipse, right click on the jar file --> Build Path --> Add to Build Path

Related

NetBeans and One-Jar Creation for Stand alone application

Please help me out,I have developed the simple application with two external jar files.While clean and build,it's creating a jar file for the application and the library folder in dist directory. When I try to execute as a jar,it's executing perfectly
But When I converted the jar into exe file using launch4j,after conversion,the execution is reporting NoClassDefFoundError.
I Hope, One-Jar is a solution for ma problem, But How to do One-Jar in Netbeans IDE or how to wrap all the dependency libraries with the application?
There are yet answers to this question here:
NetBeans - deploying all in one jar
Put external library to the JAR?

Build Failed: unable to find ojdbc .jar file

When I run the project I get an error:
C:\Users\admin\Documents\NetBeansProjects\project\nbproject\build-impl.xml:1007:
Warning: Could not find file
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar to
copy. BUILD FAILED (total time: 0 seconds)
Previously Database I used was Oracle but now I want use Mysql Server. I've already changed the code accordingly, also put mysql connector inside libraries.
Where have I stuck? Why it is giving error concerning oracle driver even if mysql server used?
P.S.
Server used: Apache Tomcat 7.0
Netbeans version: 7.4
You probably still have references to the old jar in Netbeans' build script. Right click on your project, select Properties, and look under the Build section for any reference to the old jar.
You can also edit the ant build script manually. The file path is given in the error message your provided.
You probably still have references to the old jar in Netbeans' build script. Right click on your project, select Properties, and look under the library section for any reference to the old jar.

Mysql Connector/C can't find library

I install MysqlConnector/C, add in additional include directories MySQL include directory, and add in additional library directories MySQL lib directory (there is no lib/opt directory), and write sql::mysql::MySQL_Driver and get compile error, sql namespace not found.
I have visual studio 2012, and my application is console application (with stdafx.h file). What is problem?

install MySQL JDBC driver msi

I have downloaded the JDBC driver for MySQL "mysql-connector-java-gpl-5.1.26.msi" from http://dev.mysql.com/downloads/connector/j/. But i can't figure out how to use it. The documentation at http://dev.mysql.com/doc/refman/5.6/en/connector-j-binary-installation.html says it is a zip file which has the required jar file. But what i got is a .msi file. When i execute the msi file it just starts installing and disappears. Any ideas how i can get the jar file from the msi?
The msi installation places the file at C:\Program Files\MySQL\MySQL Connector J\mysql-connector-java-5.1.26-bin.jar.
You can also download the platform independent zip file and extract the jar file whereever you want.
I had the same issue with the installer. use the drop down menu under Select Platform:, and select Platform Independent. If you don't know how to use a TAR archive, download the zip file, unzip and there is the .bin file. For eclipse, drop this into the project directory, find the file, right click, and build path. This method may cause issues if you download a java update.
You can directly used it from C:\Program Files\MySQL\MySQL Connector J\mysql-connector-java-5.1.26-bin.jar after installing the msi. If you are using IDE like Netbeans and Eclipse just go to your project then right click the Libraries folder then click add jar option then go the mysql connector directory and then select the mysql connector jar file.

Failed sqljdbc4 connection when in executable JAR

I have a GUI application that connects to a SQL Server 2008 database using sqljdbc4.jar. If I run this from the command line it works great.
However, once I wrap it into an executable JAR, I get a "No suitable driver found for jdbc:sqlserver://myServer:1433;databaseName=myDb" error. I know that my Windows system CLASSPATH is ignored once it's in a JAR, but I can't figure out include the sqljdbc4.jar within the executable JAR and get a portable application.
My most recent attempt to fix this is as follows:
My MANIFEST.MF file:
Manifest-Version: 1.0
Class-Path: lib/sqljdbc4.jar
Created-By: 1.7.0_11 (Oracle Corporation)
Main-Class: MyApp
The command I use to compile the JAR:
jar cmf MANIFEST.MF MyApp.jar MyApp.class help.html lib
My directory structure is below. I am running the jar command inside the MyApp directory.
+ MyApp
+ lib
- sqljdbc.jar
- help.html
- MANIFEST.MF
- MyApp.class
- MyApp.java
When I create the JAR and run it inside the MyApp directory, it works fine. As soon as I pull it out of the directory, I get the error. How can I make the JAR access the sqljdbc.jar that is available internally?
Thanks in advance.
When you have an executable jar MyApp.jar with entry in the manifest.mf:
Class-Path: lib/sqljdbc4.jar
This means that the jar has an external dependency to sqljdbc4.jar in the (relative) folder lib. It is not included in the jar you created! So you need to make sure that there is a lib-folder containing sqljdbc4.jar relative to that jar when you execute it. So the folder structure when executing needs to be;
+ (a folder)
+ lib
- sqljdbc.jar
- MyApp.jar