Академический Документы
Профессиональный Документы
Культура Документы
Assuming that you already have MySQL installed, the next step is to install the
connector driver. You can do this easily on the CLI by using the following
command:
The next step is to make sure that the classpath is set. You can have this set
automatically by adding this command to you bashrc file.
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
If you want to set this for all users, you should modify the /etc/environment
instead.
For those using Eclipse, you can also do this by going through the following
steps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.sql.Connection;
import java.sql.DriverManager;
class JDBCTest {
} catch (Exception e) {
e.printStackTrace();
}
}
}
Advertisements
REPORT THIS AD
Share this:
TwitterFacebookReddit
Related
Setting Up Tomcat on Ubuntu
In "Java"
Handy Shell Commands
In "Linux"
Introduction to SOAP
In "PHP"
Written by Mark Basmayor
could you show me the way to set this class path in steps:
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
jean paul
Reply
In the above program why u r not created driver class
mastan
Reply
Your code was giving me an SQL exception.
This is what worked for me..
import java.sql.Connection;
import java.sql.DriverManager;
class JDBCTest {
} catch (Exception e) {
e.printStackTrace();
}
}
}
monzta
Reply
what exception are you getting
mantis
Reply
im also getting d following exception after trying the code :
x2am
Reply
any solution i m also facing same issues
abhey
Reply
thankyou its working thanks a lot
thishanth
srikanth ganta
Reply
Pretty great post. I just stumbled upon your weblog and wished to say that
I’ve truly loved browsing your blog posts. After all I will be subscribing for
your rss feed and I’m hoping you write once more soon!
MARLA
Reply
That was the most briliant idea i’ve ever come across. Thanks alot man.
Douglas
Reply
your code give the following errors
Exception in thread “main” java.lang.NoClassDefFoundError: JDBSTest
Caused by: java.lang.ClassNotFoundException: JDBSTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: JDBSTest. Program will exit.
noel
Reply
This code will work
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
class JDBCTest {
catch (Exception e) {
System.out.println(“e”);
}
try{
st=con.createStatement();
rs=st.executeQuery(“select * from student”);
while(rs.next()) {
System.out.println(rs.getString(“Last_Name”));
}
finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
}
catch (SQLException e) {
System.out.println(e);
}
}
}
loyola
Reply
This post saved me so much time, I was able to use your post to connect Open
Office Base with Mysql database. After sudo apt-get install libmysql-java — I
created the class path by going to open office writer
>tools>options>advanced >class path (button ) and navigating to
/usr/share/java/mysql-connector-java-5.1.16.jar — then restart Open Office as
it tells you.
assuming you have Mysql client and server already installed and your
database already accessible via command line.
Damian
Reply
Thank you
James
Reply
Good day I am so thrilled I found your blog page, I really found you
by mistake, while I was researching on Aol for something else, Anyways I am
here
now and would just like to say thank you for a marvelous post and a all round
enjoyable blog (I also love the theme/design), I don’t have time to browse it all
at
the moment but I have saved it and also included your RSS
feeds, so when I have time I will be back to read a lot more, Please do keep up
the excellent job.
Reply
thank you it’s so helpful….
lp
April 24, 2014 at 9:04 am
Reply
I was looking through some of your blog posts on this internet site and I
conceive this web site is rattling informative ! Keep on posting . cadekdgcgbae
Johnb498
Reply
Thanks a lot, I’ve got a question because I’m new in ubuntu. Where is the
location for the jar file?; in which folder?
Thank you.
Cristian Camilo
Reply
You post very interesting content here. Your website deserves much more
traffic. It can go viral if you give it initial boost,
i know very useful tool that can help you, simply type in google:
svetsern traffic tips
Kazuko
Reply
it not working in my system
chandu
Reply
tried it but it doesn’t work on me. I’m using ubuntu 13.10
cath
Reply
how to connect using oracle it is giving invalid url exception
dheeraj kadam
Reply
私は 本当にも能力 書き込み |あなた} {ブログへ|あなたの内|あなたの|あなたのための構
造|形式| レイアウトでなど。それ| 変更カスタマイズ 自分 トピックまたはあなたがたの支
払った| これは、これはということですか? とにかく 珍しい希少 | それはそれはだ、書き
込み| 高品質品質 | | 優れた素敵まで保つ滞在 ピア·ツー 偉大 このようなブログ 今日で ..
国内即発 特価最安値 http://www.appliedroofingservices.com
国内即発 特価最安値
Reply
thank you.it worked. installing the package solved the problem
Sanjay Suresh
Reply
Thank you for your code to setting my mysql database connectivity in eclipse
on Ubuntu. And its work for me.
Jagdeep Yadav
Reply
thanks a ton man 🙂
vinay
Reply
Leave a Reply
REPORT THIS AD
Create a free website or blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website,
you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
:)