mysql database and java connection in Ubuntu 16.04












0















I am new to Ubuntu, I had written a simple code to connect to the DB and retrieve some data from the table. It works fine when I use the shell in SU mode whereas in the normal shell it is giving the exception "No Suitable driver found".



this is my classpath env Variable value $CLASSPATH



 bash: /usr/share/java/mysql-connector-java-5.1.38.jar: Permission denied


This is my code



import java.sql.*;
import java.util.Properties;
public class DBDemo
{
public static void main(String args){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/david","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from abc_tbl1");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getString(2));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}


Is this is the issue with the env variables or the user?
Thanks in Advance.










share|improve this question









New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

    – waltinator
    2 days ago













  • Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

    – David Raj Kanthi
    2 days ago











  • How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

    – Kulfy
    yesterday











  • using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

    – David Raj Kanthi
    yesterday











  • Which version of Java are you using? Is it openjdk or oraclejdk?

    – Kulfy
    yesterday


















0















I am new to Ubuntu, I had written a simple code to connect to the DB and retrieve some data from the table. It works fine when I use the shell in SU mode whereas in the normal shell it is giving the exception "No Suitable driver found".



this is my classpath env Variable value $CLASSPATH



 bash: /usr/share/java/mysql-connector-java-5.1.38.jar: Permission denied


This is my code



import java.sql.*;
import java.util.Properties;
public class DBDemo
{
public static void main(String args){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/david","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from abc_tbl1");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getString(2));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}


Is this is the issue with the env variables or the user?
Thanks in Advance.










share|improve this question









New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

    – waltinator
    2 days ago













  • Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

    – David Raj Kanthi
    2 days ago











  • How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

    – Kulfy
    yesterday











  • using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

    – David Raj Kanthi
    yesterday











  • Which version of Java are you using? Is it openjdk or oraclejdk?

    – Kulfy
    yesterday
















0












0








0








I am new to Ubuntu, I had written a simple code to connect to the DB and retrieve some data from the table. It works fine when I use the shell in SU mode whereas in the normal shell it is giving the exception "No Suitable driver found".



this is my classpath env Variable value $CLASSPATH



 bash: /usr/share/java/mysql-connector-java-5.1.38.jar: Permission denied


This is my code



import java.sql.*;
import java.util.Properties;
public class DBDemo
{
public static void main(String args){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/david","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from abc_tbl1");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getString(2));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}


Is this is the issue with the env variables or the user?
Thanks in Advance.










share|improve this question









New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am new to Ubuntu, I had written a simple code to connect to the DB and retrieve some data from the table. It works fine when I use the shell in SU mode whereas in the normal shell it is giving the exception "No Suitable driver found".



this is my classpath env Variable value $CLASSPATH



 bash: /usr/share/java/mysql-connector-java-5.1.38.jar: Permission denied


This is my code



import java.sql.*;
import java.util.Properties;
public class DBDemo
{
public static void main(String args){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/david","root","root");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from abc_tbl1");
while(rs.next())
System.out.println(rs.getString(1)+" "+rs.getString(2));
con.close();
}catch(Exception e){ System.out.println(e);}
}
}


Is this is the issue with the env variables or the user?
Thanks in Advance.







java mysql connection






share|improve this question









New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Kristopher Ives

2,59811322




2,59811322






New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









David Raj KanthiDavid Raj Kanthi

11




11




New contributor




David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






David Raj Kanthi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

    – waltinator
    2 days ago













  • Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

    – David Raj Kanthi
    2 days ago











  • How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

    – Kulfy
    yesterday











  • using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

    – David Raj Kanthi
    yesterday











  • Which version of Java are you using? Is it openjdk or oraclejdk?

    – Kulfy
    yesterday





















  • The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

    – waltinator
    2 days ago













  • Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

    – David Raj Kanthi
    2 days ago











  • How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

    – Kulfy
    yesterday











  • using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

    – David Raj Kanthi
    yesterday











  • Which version of Java are you using? Is it openjdk or oraclejdk?

    – Kulfy
    yesterday



















The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

– waltinator
2 days ago







The issue is probably a "permissions" issue with the /usr/share/java/mysql-connector-java-5.1.38.jar file, or directories on the path to the file. See github.com/waltinator/pathlld.git - Bash script to answer "Why can't I read/write that file?"

– waltinator
2 days ago















Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

– David Raj Kanthi
2 days ago





Even I cannot run the normal java program but it compiles well. what could be the issue with the env variables ?

– David Raj Kanthi
2 days ago













How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

– Kulfy
yesterday





How do you compile a java program? Are you using an IDE like Netbeans or Eclipse or using terminal and javac to compile?

– Kulfy
yesterday













using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

– David Raj Kanthi
yesterday





using terminal with javac and java.... its compiling any where but it is not executing anywhere in the system...

– David Raj Kanthi
yesterday













Which version of Java are you using? Is it openjdk or oraclejdk?

– Kulfy
yesterday







Which version of Java are you using? Is it openjdk or oraclejdk?

– Kulfy
yesterday












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






David Raj Kanthi is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114543%2fmysql-database-and-java-connection-in-ubuntu-16-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








David Raj Kanthi is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















David Raj Kanthi is a new contributor. Be nice, and check out our Code of Conduct.













David Raj Kanthi is a new contributor. Be nice, and check out our Code of Conduct.












David Raj Kanthi is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1114543%2fmysql-database-and-java-connection-in-ubuntu-16-04%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

數位音樂下載

When can things happen in Etherscan, such as the picture below?

格利澤436b