Can you help me how to fix that problem.
Thanks
You are missing one final configuration step.
Tools | Database Pilot. In the Pilot, select View | Options. In the
Options dialog, select the "Drivers" tab. Add your MySQL driver there.
Make sure you enter a sample URL (leave out the jdbc: at the
beginning, because it will be included automatically). You can leave
the "Tool" part blank.
After you finish all that, close the Pilot, and close and restart
JBuilder, and your MySQL driver will accessible.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
A few months ago i already did this and i don't remember to do anything
in database pilot. But it is not important.
I just want to know how can i connect to mysql. With jdbc drivers from
http://mysql.com or not.
Thanks
Try this:
package yourpackage;
import java.sql.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class TestConnection {
Connection c=null;
int first=0;
public TestConnection() {
try{
createConnection();
this.createTable();
this.populateTable();
this.printOutTestSQL();
}
catch(Exception ex){
System.out.println("Failed to get Connection to mysql
\n"+ex.getMessage());
}
}
private void createConnection() throws ClassNotFoundException,
SQLException{
Class.forName("com.mysql.jdbc.Driver");
c=DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
}
public Connection getConnection(){
if (c == null) {
try {
createConnection();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
return c;
}
public void printOutTestSQL() throws SQLException{
String sql = "Select * from myTest";
ResultSet rs=this.getConnection().createStatement().executeQuery(sql);
try{
System.out.println("Output From Database ");
System.out.print("\nColumn One");
System.out.print("\t\tColumn Two");
System.out.print("\t\tColumn Three\n");
System.out.println("____________\t\t____________\t\t____________\n");
while (rs.next()){
System.out.print(rs.getString(1));
System.out.print("\t\t"+rs.getString(2));
System.out.print("\t"+rs.getString(3)+"\n");
}
System.out.println("End Database Output");
}
finally{
rs.close();
}
}
private void createTable() throws SQLException{
if(first==0){
String sql="Create Table myTest(Test1 varchar(20) not null, Test2
varchar(20), "+
" Test3 varchar(20), Primary Key (Test1))";
try{
this.getConnection().createStatement().executeUpdate(sql);
}
catch(SQLException sqlex){
if(sqlex.getMessage().startsWith("General error, message from
server:")){
//do nothing, table exists. Continue with rest of execution.
}
System.out.println("Could not create Table, MyTest\n"+
sqlex.getMessage() );
}
}
}
private void populateTable() throws SQLException {
String arr[]= new String[3];
String sql = "";
int i=1;
if (first == 0) {
for (int x = 0; x < 4; x++) {
arr[0]="'Test Col Data " + i+"',";
arr[1]="'Test Col2 Data " + i+"',";
arr[2]="'Test Col3 Data " + i+"'";
++i;
sql = "Insert into myTest (Test1, Test2, Test3) " +
"Values("+arr[0]+arr[1]+arr[2]+")";
try{
this.getConnection().createStatement().executeUpdate(sql);
}
catch(SQLException sqlex){
if(sqlex.getMessage().startsWith("Invalid argument value")){
//Do nothing, continue..
}
else{
System.out.println("Error in entering
data\n"+sqlex.getMessage());
}
}
}
}
}
}
Now use a Main class to start this:
package yourpackage;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Main {
public Main() {
}
public static void main(String[] args) {
Main main1 = new Main();
try {
TestConnection tc = new TestConnection();
}
catch(Exception ex){
System.err.println(ex.getMessage());
}
}
}
If this does not work, then you have problems with your mySQL drivers or
your jdbc libaries in JBuilder.
If you looked at the other sample URL's for all the other database
drivers that are already configured, that should give you an idea...
But this page of the MySQL driver manual has a sample URL:
http://dev.mysql.com/doc/refman/4.1/en/cj-configuration-properties.html
Failed to get Connection to mysql
com.mysql.jdbc.Driver
Maybe i don't know where to put files that i downloaded from mysql.
I downloaded a jar file, and dir src, doc, ...
Where i must put this files?
And which files? I put only dir com/mysql/jdbc in root of jbuilder
installation(c:/borland/jbuilder/).
Thanks
To configure the JAR file as a JDBC driver, you need to go to
"Enterprise | Enterprise Setup | Database Drivers"
But i did it already five times and nothing's change.
I added in project properties in tab Path->required libraries both
mysql-connector-java-3.1.12-bin.jar and com/mysql/jdbc and it still not
working.
No i don't know what to do.
I go to the Database Pilot and options the drivers and add mysql with
sample URL property:mysql://10.0.0.2/test.
Then finally apears mysql in the Driver drop down menu in connection
property of Database. I entered user name and live the password blank. I
clicked on test connection and the next error acured:
The driver: MySQL could not be loaded. This could be a problem with the
driver itself, or that the driver is not found on the classpath.
I add host in user table in mysql, that this comupter can access to the
mysql on linux in other computer in my network.
Please any help would be appreciate.
> Please any help would be appreciate.
You need to Create a Library for the mysql drivers and then add this library
to your project.
(1) Open JBuilder
(2) Go to the Tools JBuilder Menu Option
(3) Select Configure/Libraries
(4) Click New
(5) Type in a library name (mysql for example)
(6) On the Class Tab select Add.
(7) Find where you have the .jar files for mysql
(example: mysql-connector-java-3.1.7-bin.jar )
(8) Add this jar(s) file.
(9) Click Save and/or OK.
(10) Save the Library
(11) Go to JB Menu option Project
(12) Select Project Properties
(13) Go to the Required Libraries Tab
(14) Add your new mysql library
(15) Create a New Project
(16) Name the project yourpackage.
(17) Create a New Java Class and call it TestConnection.
(18) Copy the code in my first reply to TestConnection.
(19) Create a New Java Class called Main.
(20) Copy the code I sent in my first message from the Main class.
(21) Compile the application.
(22) Run the application.
(23) If your mysql is installed correctly, then you should see data print
out.
But!
My Database still don't want to work. In Connection properties, it
doesn't work.
How to get this drivers to this property of database.
I go to the Database pilot-> option -> drivers and add MySQL with Sample
url: jdbc:mysql://10.0.0.2/test but when i go to the connection property
and select the red text mysql, set the user and test connection it writes:
failed:
com.borland.dx.dataset.DataSetException: The driver: MySQL could not be
loaded. This could be a problem with the driver itself, or that the
driver is not found on the classpath.
And i add it in the project properties -> required libraries.
Please any help
> Thank for your help. Your code has succesfully pasted the test. I try so
> many things that i don't know what was the problem, because i did it
> before already this.
>
> But!
> My Database still don't want to work. In Connection properties, it
> doesn't work.
>
If my code works, then it should be on your classpath. Try adding this line
inside of the DataModule you are using (below package name of course):
import com.mysql.jdbc.Driver;
> And i add it in the project properties -> required libraries.
> Please any help
See if this works. If the import statement turns red after a compile, then
you are missing some classes meaning the library is not complete.