Intellij MYSQl how to connect with controller class?












0















I'm new to intelliJ, just switched from eclipse. I have a few question:
I have gone to the project settings, to the libraries and added MYSQl connection. Also under modules and dependencies I have the mySql connector.
I have tried the following code in eclipse:



String dbUsername = "root";
String dbPassword = "12frimyux09";
String URL = "127.0.0.1";
String port = "3306";
String dbName = "university";
//Connection con;
String SQL;
String dbURL = "jdbc:mysql://" + URL + ":" + port + "/" + dbName + "?verifyServerCertificate=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Properties property = new Properties();

property.setProperty ("user", dbUsername);
property.setProperty("password", dbPassword);
property.setProperty("useSSL", "false");
property.setProperty("autoReconnect", "true");

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection (dbURL, property);


worked just fine, but doesn't work with intellij (I put the code in the controller class), even tried using try and catch, still no luck, I get the following error.1
Also in eclipse when I use Integer.parseInt I get alot of suggestions, but with intellij I get error and no suggestions, tried cntrl space and cntrl p, also went to file, settings, code completion and set all the ticks under parameter info, what am I doing wrong, why isn't intellji completing me???










share|improve this question























  • 1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

    – Andrey
    Nov 25 '18 at 8:21











  • Thank you, but still no change

    – Jimmy Russel
    Nov 25 '18 at 9:43











  • Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

    – Jimmy Russel
    Nov 25 '18 at 20:41
















0















I'm new to intelliJ, just switched from eclipse. I have a few question:
I have gone to the project settings, to the libraries and added MYSQl connection. Also under modules and dependencies I have the mySql connector.
I have tried the following code in eclipse:



String dbUsername = "root";
String dbPassword = "12frimyux09";
String URL = "127.0.0.1";
String port = "3306";
String dbName = "university";
//Connection con;
String SQL;
String dbURL = "jdbc:mysql://" + URL + ":" + port + "/" + dbName + "?verifyServerCertificate=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Properties property = new Properties();

property.setProperty ("user", dbUsername);
property.setProperty("password", dbPassword);
property.setProperty("useSSL", "false");
property.setProperty("autoReconnect", "true");

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection (dbURL, property);


worked just fine, but doesn't work with intellij (I put the code in the controller class), even tried using try and catch, still no luck, I get the following error.1
Also in eclipse when I use Integer.parseInt I get alot of suggestions, but with intellij I get error and no suggestions, tried cntrl space and cntrl p, also went to file, settings, code completion and set all the ticks under parameter info, what am I doing wrong, why isn't intellji completing me???










share|improve this question























  • 1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

    – Andrey
    Nov 25 '18 at 8:21











  • Thank you, but still no change

    – Jimmy Russel
    Nov 25 '18 at 9:43











  • Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

    – Jimmy Russel
    Nov 25 '18 at 20:41














0












0








0








I'm new to intelliJ, just switched from eclipse. I have a few question:
I have gone to the project settings, to the libraries and added MYSQl connection. Also under modules and dependencies I have the mySql connector.
I have tried the following code in eclipse:



String dbUsername = "root";
String dbPassword = "12frimyux09";
String URL = "127.0.0.1";
String port = "3306";
String dbName = "university";
//Connection con;
String SQL;
String dbURL = "jdbc:mysql://" + URL + ":" + port + "/" + dbName + "?verifyServerCertificate=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Properties property = new Properties();

property.setProperty ("user", dbUsername);
property.setProperty("password", dbPassword);
property.setProperty("useSSL", "false");
property.setProperty("autoReconnect", "true");

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection (dbURL, property);


worked just fine, but doesn't work with intellij (I put the code in the controller class), even tried using try and catch, still no luck, I get the following error.1
Also in eclipse when I use Integer.parseInt I get alot of suggestions, but with intellij I get error and no suggestions, tried cntrl space and cntrl p, also went to file, settings, code completion and set all the ticks under parameter info, what am I doing wrong, why isn't intellji completing me???










share|improve this question














I'm new to intelliJ, just switched from eclipse. I have a few question:
I have gone to the project settings, to the libraries and added MYSQl connection. Also under modules and dependencies I have the mySql connector.
I have tried the following code in eclipse:



String dbUsername = "root";
String dbPassword = "12frimyux09";
String URL = "127.0.0.1";
String port = "3306";
String dbName = "university";
//Connection con;
String SQL;
String dbURL = "jdbc:mysql://" + URL + ":" + port + "/" + dbName + "?verifyServerCertificate=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Properties property = new Properties();

property.setProperty ("user", dbUsername);
property.setProperty("password", dbPassword);
property.setProperty("useSSL", "false");
property.setProperty("autoReconnect", "true");

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection (dbURL, property);


worked just fine, but doesn't work with intellij (I put the code in the controller class), even tried using try and catch, still no luck, I get the following error.1
Also in eclipse when I use Integer.parseInt I get alot of suggestions, but with intellij I get error and no suggestions, tried cntrl space and cntrl p, also went to file, settings, code completion and set all the ticks under parameter info, what am I doing wrong, why isn't intellji completing me???







mysql intellij-idea






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 21:39









Jimmy RusselJimmy Russel

11




11













  • 1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

    – Andrey
    Nov 25 '18 at 8:21











  • Thank you, but still no change

    – Jimmy Russel
    Nov 25 '18 at 9:43











  • Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

    – Jimmy Russel
    Nov 25 '18 at 20:41



















  • 1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

    – Andrey
    Nov 25 '18 at 8:21











  • Thank you, but still no change

    – Jimmy Russel
    Nov 25 '18 at 9:43











  • Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

    – Jimmy Russel
    Nov 25 '18 at 20:41

















1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

– Andrey
Nov 25 '18 at 8:21





1. You need to correctly set up project that the folder where your source files are located marked as source roots: jetbrains.com/help/idea/… 2. Check that the file is not corrupted by bad encoding. Set it to UTF-8 for the files: jetbrains.com/help/idea/encoding.html

– Andrey
Nov 25 '18 at 8:21













Thank you, but still no change

– Jimmy Russel
Nov 25 '18 at 9:43





Thank you, but still no change

– Jimmy Russel
Nov 25 '18 at 9:43













Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

– Jimmy Russel
Nov 25 '18 at 20:41





Actually I corrected some of the code and placed these lines within a method, but now I get an exception that I dont have jdbc driver despite the fact that I added the library of mysql connector.

– Jimmy Russel
Nov 25 '18 at 20:41












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462598%2fintellij-mysql-how-to-connect-with-controller-class%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
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • 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%2fstackoverflow.com%2fquestions%2f53462598%2fintellij-mysql-how-to-connect-with-controller-class%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

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python