Operating System - HP-UX
1777357
Members
2630
Online
109069
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 06:49 AM
тАО03-09-2009 06:49 AM
Hi there
I'm trying to connect to mysql from java programm.
I'm not using any IDE, just vi.
jdk is installed as I'm able to create some simple programs.
I need to know how can I load the necesery libraries to be able to run following program:
package com.stardeveloper.example;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"root", "secret");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
I'm trying to connect to mysql from java programm.
I'm not using any IDE, just vi.
jdk is installed as I'm able to create some simple programs.
I need to know how can I load the necesery libraries to be able to run following program:
package com.stardeveloper.example;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JdbcExample2 {
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql:///test",
"root", "secret");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
Jesus is the King
Solved! Go to Solution.
- Tags:
- Java
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 07:17 AM
тАО03-09-2009 07:17 AM
Solution
Shalom,
It might be your server version of Java.
swlist -l product | grep jre
or jdk
http://www.hp.com/go/java
Perhaps download and install a new release on your server.
IT could be bad code.
SEP
It might be your server version of Java.
swlist -l product | grep jre
or jdk
http://www.hp.com/go/java
Perhaps download and install a new release on your server.
IT could be bad code.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 10:42 AM
тАО03-09-2009 10:42 AM
Re: Java
I've installed jdbc in my system.
Now I'm trying test it with some simple program but it wont work:
javac Jdbc11.java
Jdbc11.java:5: cannot find symbol
symbol : class Statement
location: class Jdbc11
Statement stmt;
Anyone ?
Now I'm trying test it with some simple program but it wont work:
javac Jdbc11.java
Jdbc11.java:5: cannot find symbol
symbol : class Statement
location: class Jdbc11
Statement stmt;
Anyone ?
Jesus is the King
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-10-2009 01:03 PM
тАО03-10-2009 01:03 PM
Re: Java
You need to set up the execution environment to find the JDBC libraries. First, this means setting the classpath variable to include the location of the JDBC jar files, either through the command line or environment setting:
java -classpath /some/path/to/library.jar ...
or
export CLASSPATH=/some/path/to/library.jar
java ...
Second, it depends on what type of JDBC driver this is; I haven't worked with MySQL, I don't know. If this is a type 3 (pure Java) library, then the above should work. However, if it is a type 2 (Java pass-through), then there is a thick client layer behind the JDBC. This usually requires a shared library that the Java envinmont can load, which in turn means setting the SHLIB_PATH environment variable to the location of the client libraries:
export SHLIB_PATH=/path/to/mysql/lib
export CLASSPATH=/path/to/mysql/jarfiles.jar
java ...
If you are getting a specific run-time exception, this should indicate where the problem is. A ClassNotFoundException indicates that the JVM can't find the specific JDBC implementation you need. An UnsatisfiedLinkError will indicate that the JVM can't find the shared libraries for a type 2 driver.
java -classpath /some/path/to/library.jar ...
or
export CLASSPATH=/some/path/to/library.jar
java ...
Second, it depends on what type of JDBC driver this is; I haven't worked with MySQL, I don't know. If this is a type 3 (pure Java) library, then the above should work. However, if it is a type 2 (Java pass-through), then there is a thick client layer behind the JDBC. This usually requires a shared library that the Java envinmont can load, which in turn means setting the SHLIB_PATH environment variable to the location of the client libraries:
export SHLIB_PATH=/path/to/mysql/lib
export CLASSPATH=/path/to/mysql/jarfiles.jar
java ...
If you are getting a specific run-time exception, this should indicate where the problem is. A ClassNotFoundException indicates that the JVM can't find the specific JDBC implementation you need. An UnsatisfiedLinkError will indicate that the JVM can't find the shared libraries for a type 2 driver.
Trust me, I know what I'm doing
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP