I developed a project in Netbeans Platform Application i.e. like Modules.
When i run my project from Netbeans 7.4, it works fine and doesn't show any DB exception.
Now i created a installer using Netbeans 7.4 for my project. wen i install it, the DB is also installed but its not recognizing the DB and my connection url is public final static String connectionURL = "jdbc:derby:ProjectDB;create=true;user=user;password=p#ssword";.
When i copy paste the DB alone in a location eg: " d:\project DB " and change the code as connectionURL = "jdbc:derby:D:\\project DB; create=true; user=user; password=p#ss" it works fine. But i need to create along with the installer or want my project to recognize the DB.
When i searched i got the below links
https://platform.netbeans.org/tutorials/70/nbm-crud.html
https://platform.netbeans.org/tutorials/nbm-crud.html
but dint get a solution.
Hard to tell from your description, but could you be seeing this default schema with Netbeans issue ?
Found the Solution..
launh or run the project after doing clean Build from the "dist" folder.
The new Database will be created in the "dist/project name" and you will get a error "Schema DB doesnt exists".
Now close the application and delete the DB in the "dist/project name" folder and copy-paste the DB(this i did for Derby Database) which you use for your project. And run the application agaiin.
Related
I installed NetBeans 8.0.2 with glassfish-4.1. The sample folder is present under C:\Users\Username.netbeans-derby. When I bring up NetBeans and go to the Services tab the connection to sample is present: jdbc:derby://localhost:1527/sample [app on APP] but sample is not listed under Java DB so when I try to connect to sample I get the following error "Unable to connect. Cannot establish a connection to jdbc:derby://localhost1527/sample using org.apache.derby.jdbc.ClientDriver (The connection was refused becuase the database sample was not found)."
Right click on Java DB select Create Database.
use as Database Name 'sample'
use as User Name 'app'
leave the password empty
edit
Seems there is a broken database or maybe one from an earlier Netbeans installation. Remove the sample connection in Netbeans and remove the directory %USERPROFILE%\.netbeans-derby\sample. Recreate the sample database as described above.
I had a broken database from an earlier version too, and then couldn't connect to the sample db.
I simply had to delete the .netbeans-derby directory,
then reinstalled Netbeans,
and is was ok, then.
The same thing happened to me and re-installing NetBeans did not help. After poking around the databases for a bit, I finally got mine working using the following process.
Create a new database with any properties (i.e. name, user, pw)
Navigate to your user directory \.netbeans-derby\{name}\
Copy service.properties file and paste in \.netbeans-derby\sample\
Reconnect to sample database in NetBeans
A couple extra notes:
If you configured your NetBeans database to a different location, use that location in step 2.
You may need to delete and re-create the existing sample database connection in NetBeans for it to pickup the new service.properties file.
Can I connect to a MySQL DB with JSP through another class?
Here is my my own suggestion:
...<body>
<h3>The User List</h3>
<br>
<%
// JSP/Java kode
UsersDAPInterface users = new UserDAPClass(); // This java class contains mysql connection etc.
%>
</body>...
When I do this, I get a lot of errors and exceptions, including ClassNotFound, NullPointer etc.
I also got this:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Which should mean that it doesn't have the mysql driver.. But I have imported the mysql driver so I don't know if it should be imported in a different way than usually.
Any suggestions?
Make sure that this jar file in present in WEB-INF/lib folder of your application, as long as its present there, this issue should not come.
<jsp:useBean/> use this action to load any class to jsp. This is best practice.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
This exceptions occurs due to your MySQL Connector Driver is not laoded. Use an IDE to load the driver. Manually check whether the com.mysql.jdbc.Driver is founded by writing it on Java class.
Download lib file from here and put it in your lib folder of your application. Have no idea what IDE are you using, but on Netbeans, take following steps:
Right click on your project
Select properties
In the category panel, select Libraries
Add jar folder just downloaded from Maven
You are ready.
You need to add jdbc driver class in your webapp library.
I've created new Grails project in IntellijIDEA 11.1.3 and try to run it.
When I open http://localhost:8080/application/dbdoc (accessing default action of controller grails.plugin.databasemigration.DbdocController), I keep getting message:
Changelog changelog.groovy not found
Although, file changelog.groovy exists in file system of my project in folder ./grails-app/migrations. I've generated it, using command:
grails dbm-create-changelog changelog.groovy
And now it has the following content:
databaseChangeLog = {
changeSet(author: "Edward (generated)", id: "changelog") {
// TODO add changes and preconditions here
}
}
What I need to do to make it work?
I am running IntelliJ 11.1.3 as well. I am working with Grails 2.1 and database-migration:1.1.
The database-migration plugin is used to create changelog Groovy Scripts that can be used to migrate a Database at point X in time to be compatible with new code changes you have made to your Grails App.
For instance, if your Grails App is in production today, with your Domain Classes, tables, etc. and you run grails dbm-create-changelog changelog.groovy, this will give you a baseline changelog.groovy script. Then you should run grails dbm-changelog-sync to indicate that you are up-to-date.
Let's say that you have added new Domain Classes and modified fields on existing ones. If you have been keeping up your changesets and you run grails dbm-update, the Database Migration plugin will update your database schema based on those changesets.
Here is an excellent tutorial (not mine) that I am reading/following to learn more about the database-migration plugin: Grails DB-Migration Plugin Tutorial
This question already has answers here:
The infamous java.sql.SQLException: No suitable driver found
(21 answers)
Closed 7 years ago.
Using Java, I get this error when attempting to connect to a mysql database:
java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/mysql at
java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at MyTest1.main(MyTest1.java:28)
I'm using the mysql-connector-java-5.1.18-bin.jar driver. It is in my build path. I have restarted MySQL. I've also logged on from the command line with root and no password and it connected fine. I'm not currently seeing a port 3306 in netstat. Previously I was getting a different error (I didn't change the code). The error was "jdbc mysql Access denied for user 'root'#'localhost password NO"
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
String url = "jdbc:mysql://localhost:3306/mysql";
Connection con = DriverManager.getConnection(url, "root", "");
}
catch (Exception e){
e.printStackTrace();
}
In this particular case (assuming that the Class#forName() didn't throw an exception; your code is namely continuing with running instead of throwing the exception), this SQLException means that Driver#acceptsURL() has returned false for any of the loaded drivers.
And indeed, your JDBC URL is wrong:
String url = "'jdbc:mysql://localhost:3306/mysql";
Remove the singlequote:
String url = "jdbc:mysql://localhost:3306/mysql";
See also:
Mini tutorial on MySQL + JDBC connectivity
You have to set classpath for mysql-connector.jar
In eclipse, use the build path
If you are developing any web app, you have to put mysql-connector to the lib folder of WEB-INF Directory of your web-app
When using Netbean, go under project tab and click the dropdown button there to select Libraries folder. Right Click on d Library folder and select 'Add JAR/Folder'. Locate the mysql-connectore-java.*.jar file where u have it on ur system.
This worked for me and I hope it does for u too.
Revert if u encounter any problem
This error happened to me, generally it'll be a problem due to not including the mysql-connector.jar in your eclipse project (or your IDE).
In my case, it was because of a problem on the OS.
I was editing a table in phpmyadmin, and mysql hung, I restarted Ubuntu. I cleaned the project without being successful. This morning, when I've tried the web server, it work perfectly the first time.
At the first reboot, the OS recognized that there was a problem, and after the second one, it was fixed. I hope this will save some time to somebody that "could" have this problem!
A typographical error in the string describing the database driver can also produce the error.
A string specified as:
"jdbc:mysql//localhost:3307/dbname,"usrname","password"
can result in a "no suitable driver found" error. The colon following "mysql" is missing in this example.
The correct driver string would be:
jdbc:mysql://localhost:3307/dbname,"usrname","password"
i had same problem i fix this using if developing jsp, put mysql connetor into WEB-INF->lib folder after puting that in eclipse right click and go build-path -> configure build patha in library tab add external jar file give location where lib folder is
Just telling my resolution: in my case, the libraries and projects weren't being added automatically to the classpath (i don't know why), even clicking at the "add to build path" option. So I went on run -> run configurations -> classpath and added everything I needed through there.
( If your url is correct and still get that error messege )
Do following steps to setup the Classpath in netbeans,
Create a new folder in your project workspace and add the downloaded .jar file(eg:- mysql-connector-java-5.1.35-bin.jar )
Right click your project > properties > Libraries > ADD jar/Folder
Select the jar file in that folder you just make. And click OK.
Now you will see that .jar file will be included under the libraries. Now you will not need to use the line, Class.forName("com.mysql.jdbc.Driver"); also.
If above method did not work, check the mysql-connector version (eg:- 5.1.35) and try a newer or a suitable version for you.
Goal:
Create Netbean project and put on repository (any). When other developers check out the Netbean project, they can "open project" from Netbean IDE and press execute to open browser and start testing web application.
I wrote REST web app (Toplink-essential, JAX-RS, SQL Server 2008) and this is the Netbean project other people want to open in Netbean IDE.
It's working actually except that when someone "open project" in Netbean, she still has to go to Data Source tab (next to Project and File tab), then manually create database connection by filling in the popup form (i.e typing host, db name, pick driver etc).
I found out under nbproject/setup/sun-resource.xml db drivers and name/password are defined but we had to do the first step (which is filling the popup form described earlier)
Is there way to eliminate the step? That means I can somewhere define in xml ???
Please let me know if you need more clarification.
i would comment on your post, but no such option for me atm, so have to post an answer.
What database conenction are you using ?
And try to implement a properties file rather than xml file !! and then its pretty straight forward, something like this:
MySQL
hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
hibernate.connection.driver_class =
com.mysql.jdbc.Driver
hibernate.connection.url =
jdbc:mysql://localhost/ - . . . -
hibernate.connection.username = root
hibernate.connection.password =
this might help
http://netbeans.org/kb/docs/java/project-setup.html#ide-concepts